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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 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.