You are here

public function EntityDisplayModeFormBase::form in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php \Drupal\field_ui\Form\EntityDisplayModeFormBase::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

core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php, line 76
Contains \Drupal\field_ui\Form\EntityDisplayModeFormBase.

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'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Name'),
    '#maxlength' => 100,
    '#default_value' => $this->entity
      ->label(),
  );
  $form['id'] = array(
    '#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' => array(
      'exists' => array(
        $this,
        'exists',
      ),
      'replace_pattern' => '[^a-z0-9_.]+',
    ),
  );
  return $form;
}