You are here

function content_handler_relationship::options_form in Content Construction Kit (CCK) 6.2

Same name and namespace in other branches
  1. 6.3 includes/views/handlers/content_handler_relationship.inc \content_handler_relationship::options_form()

Add a delta selector for multiple fields.

File

includes/views/handlers/content_handler_relationship.inc, line 27
Handles content relationships and deals properly with multiple values by allowing the views administrator to select deltas.

Class

content_handler_relationship
@file Handles content relationships and deals properly with multiple values by allowing the views administrator to select deltas.

Code

function options_form(&$form, &$form_state) {
  $field = $this->content_field;
  parent::options_form($form, $form_state);

  // Only add the form gadget if the field is multiple.
  if ($field['multiple']) {
    $max_delta = $field['multiple'];

    // 1 means unlimited.
    if ($max_delta == 1) {
      $max_delta = 10;
    }
    $options = array(
      '-1' => t('All'),
    );
    for ($i = 0; $i < $max_delta; $i++) {
      $options[$i] = $i + 1;
    }
    $form['delta'] = array(
      '#type' => 'select',
      '#options' => $options,
      '#default_value' => $this->options['delta'],
      '#title' => t('Delta'),
      '#description' => t('The delta allows you to select which item in a multiple value field to key the relationship off of. Select "1" to use the first item, "2" for the second item, and so on. If you select "All", each item in the field will create a new row, which may appear to cause duplicates.'),
    );
  }
}