public function YamlFormUiElementAddForm::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/ YamlFormUiElementAddForm.php, line 17
Class
- YamlFormUiElementAddForm
- Provides an add form for a form element.
Namespace
Drupal\yamlform_ui\FormCode
public function buildForm(array $form, FormStateInterface $form_state, YamlFormInterface $yamlform = NULL, $type = NULL) {
$this->yamlform = $yamlform;
$parent_key = $this
->getRequest()
->get('parent');
if ($parent_key) {
$parent_element = $yamlform
->getElementDecoded($parent_key);
if (!$parent_element) {
throw new NotFoundHttpException();
}
}
$this->element['#type'] = $type;
$this->action = $this
->t('created');
$form = parent::buildForm($form, $form_state, $yamlform, NULL, $parent_key);
if (isset($form['properties']['element']['title'])) {
$form['properties']['element']['title']['#attributes']['autofocus'] = 'autofocus';
}
return $form;
}