You are here

public function WebformAccessTypeForm::form in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_access/src/WebformAccessTypeForm.php \Drupal\webform_access\WebformAccessTypeForm::form()

Gets the actual form array to be built.

Overrides EntityForm::form

See also

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

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

File

modules/webform_access/src/WebformAccessTypeForm.php, line 17

Class

WebformAccessTypeForm
Provides a form to define a webform access type.

Namespace

Drupal\webform_access

Code

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

  /** @var \Drupal\webform_access\WebformAccessTypeInterface $webform_access_type */
  $webform_access_type = $this->entity;
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#required' => TRUE,
    '#attributes' => $webform_access_type
      ->isNew() ? [
      'autofocus' => 'autofocus',
    ] : [],
    '#default_value' => $webform_access_type
      ->label(),
  ];
  $form['id'] = [
    '#type' => 'machine_name',
    '#machine_name' => [
      'exists' => '\\Drupal\\webform_access\\Entity\\WebformAccessType::load',
      'label' => '<br/>' . $this
        ->t('Machine name'),
    ],
    '#maxlength' => 32,
    '#field_suffix' => $webform_access_type
      ->isNew() ? ' (' . $this
      ->t('Maximum @max characters', [
      '@max' => 32,
    ]) . ')' : '',
    '#required' => TRUE,
    '#disabled' => !$webform_access_type
      ->isNew(),
    '#default_value' => $webform_access_type
      ->id(),
  ];
  return parent::form($form, $form_state);
}