function mvf_handler_filter_mvf::value_form in Measured Value Field 7
Provide a simple textfield for equality
Overrides views_handler_filter_numeric::value_form
File
- views/
mvf_handler_filter_mvf.inc, line 78
Class
- mvf_handler_filter_mvf
- Base Views Filter Handler for field types defined in MVF module.
Code
function value_form(&$form, &$form_state) {
parent::value_form($form, $form_state);
// Loading any instance of this field in order to pass it down to process
// function of form element of type 'mvf_widget'.
$instance = mvf_field_instance($this->options['field_definition']);
// parent might return us differently structured $form array.
// 'value' element can be found in $form['value'] or in
// $form['value']['value'].
// And 'min' and 'max' elements might be present or not. It does so because
// the form elements depend on filter's operator state and whether it's
// exposed or not. We basically follow the same pattern. The only thing we
// want to change about it is to override parent's 'textfield' with our
// 'mvf_widget' form element introducing in such way an option to choose
// unit measure for filtering value.
$instance['label'] = '';
$value_element = array(
'#tree' => TRUE,
'#type' => 'mvf_widget',
'#field' => $this->options['field_definition'],
'#instance' => $instance,
'#entity_type' => $instance['entity_type'],
'#pre_render' => array(
'mvf_views_label_pre_render',
),
) + $this
->options_to_mvf_default_value($this->value['value']);
if (isset($form['value']['#type'])) {
$form['value'] = $value_element + $form['value'];
}
if (isset($form['value']['value']['#type'])) {
$form['value']['value'] = $value_element + $form['value']['value'];
}
if (isset($form['value']['min']['#type'])) {
$instance['label'] = t('Min');
$form['value']['min'] = array(
'#type' => 'mvf_widget',
'#field' => $this->options['field_definition'],
'#instance' => $instance,
'#entity_type' => $instance['entity_type'],
'#pre_render' => array(
'mvf_views_label_pre_render',
),
) + $this
->options_to_mvf_default_value($this->value['min']) + $form['value']['min'];
}
if (isset($form['value']['max']['#type'])) {
$instance['label'] = t('Max');
$form['value']['max'] = array(
'#type' => 'mvf_widget',
'#field' => $this->options['field_definition'],
'#instance' => $instance,
'#entity_type' => $instance['entity_type'],
'#pre_render' => array(
'mvf_views_label_pre_render',
),
) + $this
->options_to_mvf_default_value($this->value['max']) + $form['value']['max'];
}
}