public function LanguageFormBase::commonForm in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/language/src/Form/LanguageFormBase.php \Drupal\language\Form\LanguageFormBase::commonForm()
Common elements of the language addition and editing form.
2 calls to LanguageFormBase::commonForm()
- LanguageAddForm::form in core/
modules/ language/ src/ Form/ LanguageAddForm.php - Gets the actual form array to be built.
- LanguageEditForm::form in core/
modules/ language/ src/ Form/ LanguageEditForm.php - Gets the actual form array to be built.
File
- core/
modules/ language/ src/ Form/ LanguageFormBase.php, line 51 - Contains \Drupal\language\Form\LanguageFormBase.
Class
- LanguageFormBase
- Base form for language add and edit forms.
Namespace
Drupal\language\FormCode
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;
}