function EntityDisplayModeFormBase::form

Same name and namespace in other branches
  1. 9 core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php \Drupal\field_ui\Form\EntityDisplayModeFormBase::form()
  2. 10 core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php \Drupal\field_ui\Form\EntityDisplayModeFormBase::form()
  3. 11.x core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php \Drupal\field_ui\Form\EntityDisplayModeFormBase::form()

Overrides EntityForm::form

File

core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php, line 31

Class

EntityDisplayModeFormBase
Provides the generic base class for entity display mode forms.

Namespace

Drupal\field_ui\Form

Code

public function form(array $form, FormStateInterface $form_state) {
    $form['label'] = [
        '#type' => 'textfield',
        '#title' => $this->t('Name'),
        '#maxlength' => 100,
        '#default_value' => $this->entity
            ->label(),
    ];
    $form['id'] = [
        '#type' => 'machine_name',
        '#description' => $this->t('A unique machine-readable name. Can only contain lowercase letters, numbers, and underscores.'),
        '#disabled' => !$this->entity
            ->isNew(),
        '#default_value' => $this->entity
            ->id(),
        '#field_prefix' => $this->entity
            ->isNew() ? $this->entity
            ->getTargetType() . '.' : '',
        '#machine_name' => [
            'exists' => [
                $this,
                'exists',
            ],
            'replace_pattern' => '[^a-z0-9_.]+',
        ],
    ];
    return $form;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.