You are here

function relation_add_field_widget_settings_form in Relation add 7

Implements hook_field_widget_settings_form().

File

./relation_add.module, line 537
Relation Add module file.

Code

function relation_add_field_widget_settings_form($field, $instance) {
  $widget = $instance['widget'];
  $settings = $widget['settings'];
  $options = array(
    'endpoint' => 'Endpoint field',
    'custom' => 'Custom',
    'none' => 'None',
  );
  $form['relation_endpoint_label'] = array(
    '#type' => 'select',
    '#title' => t('Endpoint label'),
    '#default_value' => isset($settings['relation_endpoint_label']) ? $settings['relation_endpoint_label'] : '',
    '#options' => $options,
    '#required' => TRUE,
    '#weight' => 5,
  );
  $form['relation_endpoint_custom_label'] = array(
    '#type' => 'textfield',
    '#title' => t('Label'),
    '#default_value' => isset($settings['relation_endpoint_custom_label']) ? $settings['relation_endpoint_custom_label'] : '',
    '#states' => array(
      'visible' => array(
        ':input[name="instance[widget][settings][relation_endpoint_label]"]' => array(
          'value' => 'custom',
        ),
      ),
    ),
    '#weight' => 5,
  );
  $form['relation_endpoint_label_delta'] = array(
    '#type' => 'checkbox',
    '#title' => t('Adding endpoint delta to the label'),
    '#default_value' => isset($settings['relation_endpoint_label_delta']) ? $settings['relation_endpoint_label_delta'] : FALSE,
    '#weight' => 5,
  );
  $form['relation_endpoint_search_by_id'] = array(
    '#type' => 'checkbox',
    '#title' => t('Search endpoints by entity id if the input contains only numbers'),
    '#default_value' => isset($settings['relation_endpoint_search_by_id']) ? $settings['relation_endpoint_search_by_id'] : FALSE,
    '#weight' => 6,
  );
  $form['relation_endpoint_bundle_display'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display bundle'),
    '#description' => t('Display bundle data in the ajax label.'),
    '#default_value' => isset($settings['relation_endpoint_bundle_display']) ? $settings['relation_endpoint_bundle_display'] : FALSE,
    '#weight' => 7,
  );
  $form['relation_endpoint_iso_language_codes'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show ISO Language Codes for endpoints'),
    '#default_value' => isset($settings['relation_endpoint_iso_language_codes']) ? $settings['relation_endpoint_iso_language_codes'] : FALSE,
    '#description' => t('Add ISO Language Codes for the endpoints'),
    '#weight' => 8,
  );
  if (module_exists('relation_add_views')) {
    relation_add_views_extra_field_widget_settings_form($field, $instance, $form);
  }
  return $form;
}