function Language::buildConfigurationForm
Same name in this branch
- 11.x core/modules/language/src/Plugin/Condition/Language.php \Drupal\language\Plugin\Condition\Language::buildConfigurationForm()
Same name and namespace in other branches
- 9 core/modules/language/src/Plugin/Condition/Language.php \Drupal\language\Plugin\Condition\Language::buildConfigurationForm()
- 9 core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Language.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Language::buildConfigurationForm()
- 8.9.x core/modules/language/src/Plugin/Condition/Language.php \Drupal\language\Plugin\Condition\Language::buildConfigurationForm()
- 10 core/modules/language/src/Plugin/Condition/Language.php \Drupal\language\Plugin\Condition\Language::buildConfigurationForm()
- 10 core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Language.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Language::buildConfigurationForm()
Form constructor.
Plugin forms are embedded in other forms. In order to know where the plugin form is located in the parent form, #parents and #array_parents must be known, but these are not available during the initial build phase. In order to have these properties available when building the plugin form's elements, let this method return a form element that has a #process callback and build the rest of the form in the callback. By the time the callback is executed, the element's #parents and #array_parents properties will have been set by the form API. For more documentation on #parents and #array_parents, see \Drupal\Core\Render\Element\FormElementBase.
Parameters
array $form: An associative array containing the initial structure of the plugin form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().
Return value
array The form structure.
Overrides PluginFormInterface::buildConfigurationForm
See also
editor_image_upload_settings_form()
File
-
core/
modules/ ckeditor5/ src/ Plugin/ CKEditor5Plugin/ Language.php, line 116
Class
- Language
- CKEditor 5 Language plugin.
Namespace
Drupal\ckeditor5\Plugin\CKEditor5PluginCode
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$configured = count($this->languageManager
->getLanguages());
$predefined = count(LanguageManager::getStandardLanguageList());
$united_nations = count(LanguageManager::getUnitedNationsLanguageList());
$language_list_description_args = [
':united-nations-official' => 'https://www.un.org/en/sections/about-un/official-languages',
'@count_predefined' => $predefined,
'@count_united_nations' => $united_nations,
'@count_configured' => $configured,
];
// If Language is enabled, link to the configuration route.
if ($this->routeProvider
->getRoutesByNames([
'entity.configurable_language.collection',
])) {
$language_list_description = $this->t('The list of languages in the CKEditor "Language" dropdown can present the <a href=":united-nations-official">@count_united_nations official languages of the UN</a>, all @count_predefined languages predefined in Drupal, or the <a href=":admin-configure-languages">@count_configured languages configured for this site</a>.', $language_list_description_args + [
':admin-configure-languages' => Url::fromRoute('entity.configurable_language.collection')->toString(),
]);
}
else {
$language_list_description = $this->t('The list of languages in the CKEditor "Language" dropdown can present the <a href=":united-nations-official">@count_united_nations official languages of the UN</a>, all @count_predefined languages predefined in Drupal, or the languages configured for this site.', $language_list_description_args);
}
$form['language_list'] = [
'#title' => $this->t('Language list'),
'#title_display' => 'invisible',
'#type' => 'select',
'#options' => [
'un' => $this->t("United Nations' official languages (@count)", [
'@count' => $united_nations,
]),
'all' => $this->t('Drupal predefined languages (@count)', [
'@count' => $predefined,
]),
'site_configured' => $this->t("Site-configured languages (@count)", [
'@count' => $configured,
]),
],
'#default_value' => $this->configuration['language_list'],
'#description' => $language_list_description,
];
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.