public function FieldConfigurationForm::buildForm in Search API 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides EntityForm::buildForm
File
- src/
Form/ FieldConfigurationForm.php, line 106
Class
- FieldConfigurationForm
- Defines a form for changing a field's configuration.
Namespace
Drupal\search_api\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$field = $this
->getField();
if (!$field) {
$args['@id'] = $this
->getRequest()->attributes
->get('field_id');
$form['message'] = [
'#markup' => $this
->t('Unknown field with ID "@id".', $args),
];
return $form;
}
$args['%field'] = $field
->getLabel();
$form['#title'] = $this
->t('Edit field %field', $args);
if ($this
->getRequest()->query
->get('modal_redirect')) {
$form['title']['#markup'] = new FormattableMarkup('<h2>@title</h2>', [
'@title' => $form['#title'],
]);
Html::setIsAjax(TRUE);
}
$this->formIdAttribute = Html::getUniqueId($this
->getFormId());
$form['#id'] = $this->formIdAttribute;
$form['messages'] = [
'#type' => 'status_messages',
];
$property = $field
->getDataDefinition();
if (!$property instanceof ConfigurablePropertyInterface) {
$args['%field'] = $field
->getLabel();
$form['message'] = [
'#markup' => $this
->t('Field %field is not configurable.', $args),
];
return $form;
}
return parent::buildForm($form, $form_state);
}