You are here

function ctools_entity_from_field_edit_form in Chaos Tool Suite (ctools) 7

1 string reference to 'ctools_entity_from_field_edit_form'
entity_from_field.inc in plugins/relationships/entity_from_field.inc
Plugin to provide an relationship handler for an entity from a field.

File

plugins/relationships/entity_from_field.inc, line 204
Plugin to provide an relationship handler for an entity from a field.

Code

function ctools_entity_from_field_edit_form($form, &$form_state) {
  $field = field_info_field($form_state['plugin']['field name']);
  $conf = $form_state['conf'];
  if ($field && $field['cardinality'] != 1) {
    if ($field['cardinality'] == -1) {
      $form['delta'] = array(
        '#type' => 'textfield',
        '#title' => t('Delta'),
        '#description' => t('The relationship can only create one context, but multiple items can be related. Please select which one. Since this can have unlimited items, type in the number you want. The first one will be 0.'),
        '#default_value' => !empty($conf['delta']) ? $conf['delta'] : 0,
      );
    }
    else {
      $form['delta'] = array(
        '#type' => 'select',
        '#title' => t('Delta'),
        '#description' => t('The relationship can only create one context, but multiple items can be related. Please select which one.'),
        '#options' => range(1, $field['cardinality']),
        '#default_value' => !empty($conf['delta']) ? $conf['delta'] : 0,
      );
    }
  }
  return $form;
}