You are here

public function EntityDisplayModeAddForm::buildForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/field_ui/src/Form/EntityDisplayModeAddForm.php \Drupal\field_ui\Form\EntityDisplayModeAddForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides EntityForm::buildForm

File

core/modules/field_ui/src/Form/EntityDisplayModeAddForm.php, line 28
Contains \Drupal\field_ui\Form\EntityDisplayModeAddForm.

Class

EntityDisplayModeAddForm
Provides the add form for entity display modes.

Namespace

Drupal\field_ui\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL) {
  $this->targetEntityTypeId = $entity_type_id;
  $form = parent::buildForm($form, $form_state);

  // Change replace_pattern to avoid undesired dots.
  $form['id']['#machine_name']['replace_pattern'] = '[^a-z0-9_]+';
  $definition = $this->entityManager
    ->getDefinition($this->targetEntityTypeId);
  $form['#title'] = $this
    ->t('Add new %label @entity-type', array(
    '%label' => $definition
      ->getLabel(),
    '@entity-type' => $this->entityType
      ->getLowercaseLabel(),
  ));
  return $form;
}