You are here

function cck_form_alter in Content Construction Kit (CCK) 7.3

Add fields to allowed values form to allow users to input a function or a PHP snippet that will return the allowed values.

File

./cck.module, line 28
Allows administrators to use php code snippets to define allowed values or default values. The snippets are stored in a database table and retrieved in callback functions.

Code

function cck_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'field_ui_field_settings_form':
      $field = field_info_field($form['field']['field_name']['#value']);
      if ($field['module'] == 'list') {

        // @todo : core should put that for us.
        $form['#field'] = $field;
        cck_allowed_values_form($form, $form_state, $field);
        $form['#validate'][] = 'cck_allowed_values_validate';
      }
      break;
    case 'field_ui_field_edit_form':
      $field = $form['#field'];
      if ($field['module'] == 'list') {
        cck_default_value_form($form, $form_state, $field);
        cck_allowed_values_form($form, $form_state, $field);
        $form['#validate'][] = 'cck_allowed_values_validate';
        $form['#validate'][] = 'cck_default_value_validate';
      }
      break;
  }
}