function relation_handler_relationship::options_form in Relation 7
Let the user choose r_index.
Overrides views_handler_relationship::options_form
File
- views/
relation_handler_relationship.inc, line 23 - Views relationship support.
Class
- relation_handler_relationship
- @file Views relationship support.
Code
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
// Check if this relation is entity-to-entity or entity-to-relation / relation-to-entity.
$endpoints_twice = isset($this->definition['entity_type_left']) && isset($this->definition['entity_type_right']);
if ($this->definition['directional']) {
$form['r_index'] = array(
'#type' => 'select',
'#options' => array(
-1 => t('Any'),
0 => t('Source'),
1 => t('Target'),
),
'#title' => t('Position of the relationship base'),
'#default_value' => $this->options['r_index'],
// check_plain()'d in the definition.
'#description' => t('Select whether the entity you are adding the relationship to is source or target of !relation_type_label relation.', array(
'!relation_type_label' => $this->definition['label'],
)),
);
}
foreach (array(
'left',
'right',
) as $key) {
if (isset($this->definition['entity_type_' . $key])) {
$form['entity_deduplication_' . $key] = array(
'#type' => 'checkbox',
'#title' => $endpoints_twice ? t('Avoid @direction @type duplication', array(
'@direction' => t($key),
'@type' => $this->definition['entity_type_' . $key],
)) : t('Avoid @type duplication', array(
'@type' => $this->definition['entity_type_' . $key],
)),
'#default_value' => $this->options['entity_deduplication_' . $key],
'#description' => t('When creating a chain of Views relationships for example from node to relation and then from relation to node (both via the same relation type) then each node will display on both ends. Check this option to avoid this kind of duplication.'),
);
}
}
}