public LanguageFormBase::commonForm(array &$form)
Common elements of the language addition and editing form.
File
- core/modules/language/src/Form/LanguageFormBase.php, line 46
Class
- LanguageFormBase
- Base form for language add and edit forms.
Namespace
Drupal\language\Form
Code
public function commonForm(array &$form) {
/* @var $language \Drupal\language\ConfigurableLanguageInterface */
$language = $this->entity;
if ($language->getId()) {
$form['langcode_view'] = array(
'#type' => 'item',
'#title' => $this->t('Language code'),
'#markup' => $language->id()
);
$form['langcode'] = array(
'#type' => 'value',
'#value' => $language->id()
);
}
else {
$form['langcode'] = array(
'#type' => 'textfield',
'#title' => $this->t('Language code'),
'#maxlength' => 12,
'#required' => TRUE,
'#default_value' => '',
'#disabled' => FALSE,
'#description' => $this->t('Use language codes as <a href=":w3ctags">defined by the W3C</a> for interoperability. <em>Examples: "en", "en-gb" and "zh-hant".</em>', array(':w3ctags' => 'http://www.w3.org/International/articles/language-tags/')),
);
}
$form['label'] = array(
'#type' => 'textfield',
'#title' => $this->t('Language name'),
'#maxlength' => 64,
'#default_value' => $language->label(),
'#required' => TRUE,
);
$form['direction'] = array(
'#type' => 'radios',
'#title' => $this->t('Direction'),
'#required' => TRUE,
'#description' => $this->t('Direction that text in this language is presented.'),
'#default_value' => $language->getDirection(),
'#options' => array(
LanguageInterface::DIRECTION_LTR => $this->t('Left to right'),
LanguageInterface::DIRECTION_RTL => $this->t('Right to left'),
),
);
return $form;
}
Please login to continue.