/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $form['update_entity_type'] = [ '#type' => 'value', '#value' => $this->getCurrentEntityType($form_state), ]; return $form; }
/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $form['label'] = array( '#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $this->entity->label(), '#description' => $this->t("Label for the Scheduled update type."), '#required' => TRUE, '#weight' => -110, ); $form['id'] = array( '#type' => 'machine_name', '#default_value' => $this->entity->id(), '#machine_name' => array( 'exists' => '\Drupal\scheduled_updates\Entity\ScheduledUpdateType::load', ), '#disabled' => !$this->entity->isNew(), '#weight' => -100, ); $default_type = $this->getCurrentEntityType($form_state); $disabled = !$this->entity->isNew(); $form['update_entity_type'] = [ '#type' => 'select', '#title' => $this->t('Entity Type'), '#description' => $this->t('The entity type to update. This <strong>cannot</strong> be changed after this type is created.'), '#options' => $this->entityTypeOptions(), '#default_value' => $default_type, '#required' => TRUE, // @todo why doesn't this work? '#disabled' => $disabled, '#weight' => -90, ]; // @todo Remove when bug is fixed. if (!$form['update_entity_type']['#disabled']) { // Just to duplicate issues on d.o for now. $form['update_entity_type']['#description'] .= '<br /><strong>**KNOWN BUG**</strong> : Ajax error when selecting one entity type and then selecting another: https://www.drupal.org/node/2643934'; } $form['update_entity_type'] += $this->typeDependentAjax(); $form['field_map'] = $this->createFieldMapElements(); /* You will need additional form elements for your custom properties. */ return $form; }