public function WebformSubmissionFieldFilter::valueForm in Webform Views Integration 8.5
Provide a simple textfield for equality
Overrides StringFilter::valueForm
3 calls to WebformSubmissionFieldFilter::valueForm()
- WebformSubmissionComputedFilter::valueForm in src/
Plugin/ views/ filter/ WebformSubmissionComputedFilter.php - Provide a simple textfield for equality
- WebformSubmissionSelectOtherFilter::valueForm in src/
Plugin/ views/ filter/ WebformSubmissionSelectOtherFilter.php - Provide a simple textfield for equality
- WebformSubmissionTermCheckboxesFilter::valueForm in src/
Plugin/ views/ filter/ WebformSubmissionTermCheckboxesFilter.php - Provide a simple textfield for equality
3 methods override WebformSubmissionFieldFilter::valueForm()
- WebformSubmissionComputedFilter::valueForm in src/
Plugin/ views/ filter/ WebformSubmissionComputedFilter.php - Provide a simple textfield for equality
- WebformSubmissionSelectOtherFilter::valueForm in src/
Plugin/ views/ filter/ WebformSubmissionSelectOtherFilter.php - Provide a simple textfield for equality
- WebformSubmissionTermCheckboxesFilter::valueForm in src/
Plugin/ views/ filter/ WebformSubmissionTermCheckboxesFilter.php - Provide a simple textfield for equality
File
- src/
Plugin/ views/ filter/ WebformSubmissionFieldFilter.php, line 137
Class
- WebformSubmissionFieldFilter
- Filter based on value of a webform submission.
Namespace
Drupal\webform_views\Plugin\views\filterCode
public function valueForm(&$form, FormStateInterface $form_state) {
$element = $this
->getWebformElement();
$element['#default_value'] = $this->value;
$element['#required'] = FALSE;
$operator = $form_state
->get([
'webform_views',
'filter_operator',
]) ?: $this->operator;
$operator_definition = $this
->operators()[$operator];
// Swap the type of value if the current operator dictates doing so.
if (isset($operator_definition['webform_views_element_type']) && $operator_definition['webform_views_element_type'] != self::ELEMENT_TYPE) {
$element['#type'] = $operator_definition['webform_views_element_type'];
unset($element['#options']);
}
// Wrap the value with a container that will be used for AJAX.
$html_id = Html::getUniqueId($this->pluginId);
$form_state
->set([
'webform_views',
'filter_value_form_wrapper_id',
], $html_id);
$theme_wrappers = $this
->getFormElementProperty($element, '#theme_wrappers', []);
$theme_wrappers['container'] = [
'#attributes' => [
'id' => $html_id,
],
];
$element['#theme_wrappers'] = $theme_wrappers;
$process = $this
->getFormElementProperty($element, '#process', []);
// We wanna run as the 1st process since we might change the type of the
// element and thus the ongoing processes may become obsolete.
array_unshift($process, [
self::class,
'processValueForm',
]);
$element['#process'] = $process;
// We will need the definition of operators in the process callback and at
// that moment we will in static context without access to methods of this
// object. So we thoughtfully attach definition of all operators to the form
// element itself.
$element['#webform_views_filter']['operators'] = $this
->operators();
$form['value'] = $element;
}