function ConfigTranslationFormBase::submitForm
Same name in other branches
- 8.9.x core/modules/config_translation/src/Form/ConfigTranslationFormBase.php \Drupal\config_translation\Form\ConfigTranslationFormBase::submitForm()
- 10 core/modules/config_translation/src/Form/ConfigTranslationFormBase.php \Drupal\config_translation\Form\ConfigTranslationFormBase::submitForm()
- 11.x core/modules/config_translation/src/Form/ConfigTranslationFormBase.php \Drupal\config_translation\Form\ConfigTranslationFormBase::submitForm()
Overrides FormInterface::submitForm
2 calls to ConfigTranslationFormBase::submitForm()
- ConfigTranslationAddForm::submitForm in core/
modules/ config_translation/ src/ Form/ ConfigTranslationAddForm.php - Form submission handler.
- ConfigTranslationEditForm::submitForm in core/
modules/ config_translation/ src/ Form/ ConfigTranslationEditForm.php - Form submission handler.
2 methods override ConfigTranslationFormBase::submitForm()
- ConfigTranslationAddForm::submitForm in core/
modules/ config_translation/ src/ Form/ ConfigTranslationAddForm.php - Form submission handler.
- ConfigTranslationEditForm::submitForm in core/
modules/ config_translation/ src/ Form/ ConfigTranslationEditForm.php - Form submission handler.
File
-
core/
modules/ config_translation/ src/ Form/ ConfigTranslationFormBase.php, line 198
Class
- ConfigTranslationFormBase
- Provides a base form for configuration translations.
Namespace
Drupal\config_translation\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_values = $form_state->getValue([
'translation',
'config_names',
]);
foreach ($form_values as $name => $value) {
$schema = $this->typedConfigManager
->get($name);
// Set configuration values based on form submission and source values.
$base_config = $this->configFactory()
->getEditable($name);
$config_translation = $this->languageManager
->getLanguageConfigOverride($this->language
->getId(), $name);
$element = $this->createFormElement($schema);
$element->setConfig($base_config, $config_translation, $value);
// If no overrides, delete language specific configuration file.
$saved_config = $config_translation->get();
if (empty($saved_config)) {
$config_translation->delete();
$this->messenger()
->addStatus($this->t('@language translation was not added. To add a translation, you must modify the configuration.', [
'@language' => $this->language
->getName(),
]));
}
else {
$config_translation->save();
$this->messenger()
->addStatus($this->t('Successfully saved @language translation.', [
'@language' => $this->language
->getName(),
]));
}
}
$form_state->setRedirect($this->mapper
->getOverviewRoute(), $this->mapper
->getOverviewRouteParameters());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.