public function AutocompletionConfigurationAddForm::buildForm in Search Autocomplete 8
Same name and namespace in other branches
- 2.x src/Form/AutocompletionConfigurationAddForm.php \Drupal\search_autocomplete\Form\AutocompletionConfigurationAddForm::buildForm()
Overrides Drupal\Core\Entity\EntityFormController::form() and Drupal\search_autocomplete\Form\AutocompletionConfigurationFormBase::form()
Builds the entity add form.
Parameters
array $form: An associative array containing the structure of the form.
array $form_state: An associative array containing the current state of the form.
Return value
array An associative array containing the autocompletion_configuration add/edit form.
Overrides AutocompletionConfigurationFormBase::buildForm
File
- src/
Form/ AutocompletionConfigurationAddForm.php, line 33
Class
- AutocompletionConfigurationAddForm
- Class AutocompletionConfigurationAddForm.
Namespace
Drupal\search_autocomplete\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
// Get anything we need from the base class.
$form = parent::buildForm($form, $form_state);
// Get default selector from URL if available.
$selector = '';
if (isset($_REQUEST['selector'])) {
$selector = urldecode($_REQUEST['selector']);
}
// Selector.
$form['selector'] = [
'#type' => 'textfield',
'#title' => $this
->t('ID selector this configuration should apply to'),
'#description' => 'Enter a valid query selector for this configuration. This should be an ID or a class targeting an input field.',
'#default_value' => $selector ? $selector : $this->entity
->getSelector(),
];
// Return the form.
return $form;
}