$options = parent::defineOptions();
$options['expose']['contains']['required'] = ['default' => FALSE];
+ $options['expose']['contains']['placeholder'] = ['default' => ''];
return $options;
}
+ /**
+ * {@inheritdoc}
+ */
+ public function defaultExposeOptions() {
+ parent::defaultExposeOptions();
+ $this->options['expose']['placeholder'] = NULL;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function buildExposeForm(&$form, FormStateInterface $form_state) {
+ parent::buildExposeForm($form, $form_state);
+ $form['expose']['placeholder'] = [
+ '#type' => 'textfield',
+ '#default_value' => $this->options['expose']['placeholder'],
+ '#title' => $this->t('Placeholder'),
+ '#size' => 40,
+ '#description' => $this->t('Hint text that appears inside the field when empty.'),
+ ];
+ }
+
/**
* This kind of construct makes it relatively easy for a child class
* to add or remove functionality by overriding this function and
'#size' => 30,
'#default_value' => $this->value,
];
+ if (!empty($this->options['expose']['placeholder'])) {
+ $form['value']['#attributes']['placeholder'] = $this->options['expose']['placeholder'];
+ }
$user_input = $form_state->getUserInput();
if ($exposed && !isset($user_input[$identifier])) {
$user_input[$identifier] = $this->value;