public function DomainPathForm::buildForm in Domain Path 8
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
- src/
Form/ DomainPathForm.php, line 84
Class
- DomainPathForm
- Form controller for the domain_path entity edit forms.
Namespace
Drupal\domain_path\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
/* @var $entity \Drupal\domain_path\Entity\DomainPath */
$form = parent::buildForm($form, $form_state);
$options = [];
$entity = $form_state
->getFormObject()
->getEntity();
foreach ($this->languageManager
->getLanguages() as $language) {
$options[$language
->getId()] = $language
->getName();
}
$form['language'] = [
'#title' => $this
->t('Language'),
'#type' => 'language_select',
'#options' => $options,
'#default_value' => $entity
->getLanguageCode(),
'#languages' => Language::STATE_ALL,
];
return $form;
}