You are here

public function ContactFormCloneForm::form in Contact Storage 8

Gets the actual form array to be built.

Overrides ContactFormEditForm::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

File

src/Form/ContactFormCloneForm.php, line 58

Class

ContactFormCloneForm
Defines a class for cloning a contact form.

Namespace

Drupal\contact_storage\Form

Code

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

  // Add #process and #after_build callbacks.
  $form['#process'][] = '::processForm';
  $form['#after_build'][] = '::afterBuild';
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => '',
    '#description' => $this
      ->t("Example: 'website feedback' or 'product information'."),
    '#required' => TRUE,
  ];
  $form['id'] = [
    '#type' => 'machine_name',
    '#default_value' => '',
    '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
    '#machine_name' => [
      'exists' => '\\Drupal\\contact\\Entity\\ContactForm::load',
    ],
  ];
  return $form;
}