You are here

public function YamlFormSubmissionForm::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 EntityForm::buildForm

1 call to YamlFormSubmissionForm::buildForm()
YamlFormTemplatesSubmissionPreviewForm::buildForm in modules/yamlform_templates/src/YamlFormTemplatesSubmissionPreviewForm.php
Form constructor.
1 method overrides YamlFormSubmissionForm::buildForm()
YamlFormTemplatesSubmissionPreviewForm::buildForm in modules/yamlform_templates/src/YamlFormTemplatesSubmissionPreviewForm.php
Form constructor.

File

src/YamlFormSubmissionForm.php, line 153

Class

YamlFormSubmissionForm
Provides a form to collect and edit submissions.

Namespace

Drupal\yamlform

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  /* @var $yamlform_submission \Drupal\yamlform\YamlFormSubmissionInterface */
  $yamlform_submission = $this
    ->getEntity();
  $yamlform = $this
    ->getYamlForm();

  // This submission form is based on the current URL, and hence it depends
  // on the 'url' cache context.
  $form['#cache']['contexts'][] = 'url';

  // Add this form and the form settings to the cache tags.
  $form['#cache']['tags'][] = 'config:yamlform.settings';

  // Add the form as a cacheable dependency.
  \Drupal::service('renderer')
    ->addCacheableDependency($form, $this
    ->getYamlForm());

  // Display status messages.
  $this
    ->displayMessages($form, $form_state);

  // Build the form.
  $form = parent::buildForm($form, $form_state);

  // Alter form via form handler.
  $this
    ->getYamlForm()
    ->invokeHandlers('alterForm', $form, $form_state, $yamlform_submission);

  // Call custom form alter hook.
  $form_id = $this
    ->getFormId();
  $this->thirdPartySettingsManager
    ->alter('yamlform_submission_form', $form, $form_state, $form_id);
  return $form;
}