public function references_handler_relationship::options_form in References 7.2
Add a delta selector for multiple fields.
@codingStandardsIgnoreStart
Overrides views_handler_relationship::options_form
File
- views/
references_handler_relationship.inc, line 31 - Provide relationship handler for reference fields.
Class
- references_handler_relationship
- Default class for handler relationship.
Code
public function options_form(&$form, &$form_state) {
// @codingStandardsIgnoreEnd
parent::options_form($form, $form_state);
$field = field_info_field($this->definition['field_name']);
// Only add the delta selector if the field is multiple.
if ($field['cardinality']) {
$max_delta = $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED ? 10 : $field['cardinality'];
$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.'),
);
}
}