public function GoogleAnalyticsString::valueForm in Google Analytics Reports 8.3
Provide a simple textfield for equality.
Overrides FilterPluginBase::valueForm
File
- src/
Plugin/ views/ filter/ GoogleAnalyticsString.php, line 85
Class
- GoogleAnalyticsString
- Basic textfield filter to handle string filtering commands.
Namespace
Drupal\google_analytics_reports\Plugin\views\filterCode
public function valueForm(&$form, FormStateInterface $form_state) {
parent::valueForm($form, $form_state);
$values = $form_state
->getValues();
// 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($values['exposed'])) {
$identifier = $this->options['expose']['identifier'];
if (empty($this->options['expose']['use_operator']) || empty($this->options['expose']['operator_id'])) {
// Exposed and locked.
$which = in_array($this->operator, $this
->operatorValues(1)) ? 'value' : 'none';
}
else {
$source = 'edit-' . Html::getUniqueId($this->options['expose']['operator_id']);
}
}
if ($which == 'all' || $which == 'value') {
$form['value'] = [
'#type' => 'textfield',
'#title' => $this
->t('Value'),
'#size' => 30,
'#default_value' => $this->value,
];
if (!empty($values['exposed']) && !isset($values['input'][$identifier])) {
$values['input'][$identifier] = $this->value;
}
if ($which == 'all') {
$form['value'] += [
'#dependency' => [
$source => $this
->operatorValues(1),
],
];
}
}
if (!isset($form['value'])) {
// Ensure there is something in the 'value'.
$form['value'] = [
'#type' => 'value',
'#value' => NULL,
];
}
}