You are here

public function WebformUiElementDuplicateForm::buildForm in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_ui/src/Form/WebformUiElementDuplicateForm.php \Drupal\webform_ui\Form\WebformUiElementDuplicateForm::buildForm()

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 WebformUiElementFormBase::buildForm

File

modules/webform_ui/src/Form/WebformUiElementDuplicateForm.php, line 23

Class

WebformUiElementDuplicateForm
Provides a duplicate webform for a webform element.

Namespace

Drupal\webform_ui\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, WebformInterface $webform = NULL, $key = NULL, $parent_key = NULL, $type = NULL) {
  if (empty($key)) {
    throw new NotFoundHttpException();
  }
  $this->element = $webform
    ->getElementDecoded($key);
  if ($this->element === NULL) {
    throw new NotFoundHttpException();
  }
  $element_initialized = $webform
    ->getElement($key);
  $t_args = [
    '@title' => WebformElementHelper::getAdminTitle($element_initialized),
  ];
  $form['#title'] = $this
    ->t('Duplicate @title element', $t_args);
  $this->action = $this
    ->t('created');
  return parent::buildForm($form, $form_state, $webform, NULL, $element_initialized['#webform_parent_key']);
}