You are here

public function YamlFormUiElementDuplicateForm::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/YamlFormUiElementDuplicateForm.php, line 17

Class

YamlFormUiElementDuplicateForm
Provides a duplicate form for a form element.

Namespace

Drupal\yamlform_ui\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, YamlFormInterface $yamlform = NULL, $key = NULL) {
  if (empty($key)) {
    throw new NotFoundHttpException();
  }
  $this->element = $yamlform
    ->getElementDecoded($key);
  if ($this->element === NULL) {
    throw new NotFoundHttpException();
  }
  $element_initialized = $yamlform
    ->getElement($key);
  $form['#title'] = $this
    ->t('Duplicate @title element', [
    '@title' => !empty($this->element['#title']) ? $this->element['#title'] : $key,
  ]);
  $this->action = $this
    ->t('created');
  return parent::buildForm($form, $form_state, $yamlform, NULL, $element_initialized['#yamlform_parent_key']);
}