Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $form['label'] = ['#type' => 'textfield', '#title' => $this->t('Label'), '#description' => $this->t('The label for this variant.'), '#default_value' => $this->entity->label() ?: (string) $this->getVariantPlugin()->adminLabel(), '#maxlength' => '255'];
     $form['id'] = ['#type' => 'machine_name', '#disabled' => !$this->entity->isNew(), '#default_value' => !$this->entity->isNew() ? $this->entity->id() : '', '#machine_name' => ['exists' => [$this, 'exists']]];
     // Allow the variant to add to the form.
     $form['variant_settings'] = $this->getVariantPlugin()->buildConfigurationForm([], $form_state);
     $form['variant_settings']['#tree'] = TRUE;
     $form['actions'] = ['#type' => 'actions'];
     $form['actions']['submit'] = ['#type' => 'submit', '#value' => 'Add/Edit', '#button_type' => 'primary'];
     return $form;
 }