function matrix_handler_filter::value_form in Matrix field 8.2
Same name in this branch
- 8.2 views/matrix_handler_filter.inc \matrix_handler_filter::value_form()
- 8.2 src/matrix_handler_filter.php \Drupal\matrix\matrix_handler_filter::value_form()
Same name and namespace in other branches
- 7.2 views/matrix_handler_filter.inc \matrix_handler_filter::value_form()
Provide a simple textfield for equality
File
- views/
matrix_handler_filter.inc, line 73
Class
- matrix_handler_filter
- Basic textfield filter to handle string filtering commands including equality, like, not like, etc.
Code
function value_form(&$form, &$form_state) {
if (isset($this->options['value'])) {
list($row_default, $col_default, $value_default) = explode('_____', $this->value);
}
// We have to make some choices when creating this as an exposed
// filter form. For example, if the operator is locked and thus
// not rendered, we can't render dependencies; instead we only
// render the form items we need.
$which = 'all';
if (!empty($form['operator'])) {
$source = $form['operator']['#type'] == 'radios' ? 'radio:options[operator]' : 'edit-options-operator';
}
if (!empty($form_state['exposed'])) {
$identifier = $this->options['expose']['identifier'];
if (empty($this->options['expose']['use_operator']) || empty($this->options['expose']['operator'])) {
// exposed and locked.
$which = in_array($this->operator, $this
->operator_values(1)) ? 'value' : 'none';
}
else {
$source = 'edit-' . \Drupal\Component\Utility\Html::getId($this->options['expose']['operator']);
}
}
if ($which == 'all' || $which == 'value') {
$form['value'] = array(
'#type' => 'textfield',
'#title' => t('Value'),
'#size' => 30,
'#default_value' => $value_default,
);
if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier])) {
$form_state['input'][$identifier] = $this->value;
}
if ($which == 'all') {
$form['value'] += array(
'#process' => array(
'ctools_dependent_process',
),
'#dependency' => array(
$source => $this
->operator_values(1),
),
'#prefix' => '<div id="edit-options-value-wrapper">',
);
$form['row'] = array(
'#type' => 'select',
'#title' => t('Row'),
'#options' => $this
->row_list(),
'#default_value' => $row_default,
'#process' => array(
'ctools_dependent_process',
),
);
$form['col'] = array(
'#type' => 'select',
'#title' => t('Column'),
'#options' => $this
->col_list(),
'#default_value' => $col_default,
'#process' => array(
'ctools_dependent_process',
),
'#suffix' => '</div>',
);
}
}
if (!isset($form['value'])) {
// Ensure there is something in the 'value'.
$form['value'] = array(
'#type' => 'value',
'#value' => NULL,
);
}
if (!isset($form['row'])) {
// Ensure there is something in the 'row'.
$form['row'] = array(
'#type' => 'value',
'#value' => NULL,
);
}
if (!isset($form['col'])) {
// Ensure there is something in the 'value'.
$form['col'] = array(
'#type' => 'value',
'#value' => NULL,
);
}
}