public function YamlFormUiElementEditForm::buildForm in YAML Form 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 YamlFormUiElementFormBase::buildForm
File
- modules/
yamlform_ui/ src/ Form/ YamlFormUiElementEditForm.php, line 19
Class
- YamlFormUiElementEditForm
- Provides an edit form for a form element.
Namespace
Drupal\yamlform_ui\FormCode
public function buildForm(array $form, FormStateInterface $form_state, YamlFormInterface $yamlform = NULL, $key = NULL) {
$this->element = $yamlform
->getElementDecoded($key);
if ($this->element === NULL) {
throw new NotFoundHttpException();
}
// Handler changing element type.
if ($type = $this
->getRequest()
->get('type')) {
$yamlform_element = $this
->getYamlFormElement();
$related_types = $yamlform_element
->getRelatedTypes($this->element);
if (!isset($related_types[$type])) {
throw new NotFoundHttpException();
}
$this->originalType = $this->element['#type'];
$this->element['#type'] = $type;
}
// Issue: #title is display as modal dialog's title and can't be escaped.
// Workaround: Filter and define @title as safe markup.
$form['#title'] = $this
->t('Edit @title element', [
'@title' => !empty($this->element['#title']) ? new FormattableMarkup(Xss::filterAdmin($this->element['#title']), []) : $key,
]);
$this->action = $this
->t('updated');
return parent::buildForm($form, $form_state, $yamlform, $key);
}