You are here

function ref_field_field_settings_form in (Entity)Reference Field Synchronization 7

Implements hook_field_settings_form().

The ajax update needs to be done on a hook_form_FORM-ID_alter().

See also

ref_field_form_field_ui_field_settings_form_alter().

File

./ref_field.module, line 56

Code

function ref_field_field_settings_form($field, $instance, $has_data) {
  $form = array();
  $options = array(
    '' => t('- Select -'),
  );
  foreach (entity_get_info() as $entity => $data) {
    $options[$entity] = $data['label'];
  }
  if (!$has_data) {

    // Show entities and bundles in two fields
    // One field can get too large
    $form['entity'] = array(
      '#title' => t('Entity'),
      '#description' => t('Select the entity type this field will reference.'),
      '#type' => 'select',
      '#default_value' => isset($field['settings']['entity']) ? $field['settings']['entity'] : '',
      '#required' => TRUE,
      '#ajax' => array(
        'callback' => '_ref_field_field_settings_ajax',
        'wrapper' => '',
      ),
      '#element_validate' => array(
        '_ref_field_field_entity_settings_form_validate',
      ),
      '#options' => $options,
    );
  }
  $form['bundles'] = array();
  _ref_field_field_settings_bundles($form['bundles'], $field['settings']['entity'], $has_data);
  return $form;
}