Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, PageInterface $page = NULL, $name = '')
 {
     $this->page = $page;
     $parameter = $this->page->getParameter($name);
     $form['machine_name'] = ['#type' => 'value', '#value' => $name];
     $form['label'] = ['#type' => 'textfield', '#title' => $this->t('Label'), '#default_value' => $parameter['label'] ?: ucfirst($parameter['machine_name']), '#states' => ['invisible' => [':input[name="type"]' => ['value' => static::NO_CONTEXT_KEY]]]];
     $form['type'] = ['#type' => 'select', '#title' => $this->t('Type'), '#required' => TRUE, '#options' => $this->buildParameterTypeOptions(), '#default_value' => $parameter['type']];
     $form['actions'] = ['#type' => 'actions'];
     $form['actions']['submit'] = ['#type' => 'submit', '#value' => $this->t('Update parameter'), '#button_type' => 'primary'];
     return $form;
 }
 /**
  * Route title callback.
  *
  * @param \Drupal\page_manager\PageInterface $page
  *   The page entity.
  * @param string $name
  *   The parameter context name.
  *
  * @return string
  *   The title for the parameter edit form.
  */
 public function editParameterTitle(PageInterface $page, $name)
 {
     return $this->t('Edit @label parameter', ['@label' => $page->getParameter($name)['label']]);
 }