EntityDisplayModeFormBase::form

public EntityDisplayModeFormBase::form(array $form, FormStateInterface $form_state)

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 71

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;
}
doc_Drupal
2016-10-29 09:05:45
Comments
Leave a Comment

Please login to continue.