public function TranslateEditForm::validateForm in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/locale/src/Form/TranslateEditForm.php \Drupal\locale\Form\TranslateEditForm::validateForm()
Form validation handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormBase::validateForm
File
- core/
modules/ locale/ src/ Form/ TranslateEditForm.php, line 159 - Contains \Drupal\locale\Form\TranslateEditForm.
Class
- TranslateEditForm
- Defines a translation edit form.
Namespace
Drupal\locale\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$langcode = $form_state
->getValue('langcode');
foreach ($form_state
->getValue('strings') as $lid => $translations) {
foreach ($translations['translations'] as $key => $value) {
if (!locale_string_is_safe($value)) {
$form_state
->setErrorByName("strings][{$lid}][translations][{$key}", $this
->t('The submitted string contains disallowed HTML: %string', array(
'%string' => $value,
)));
$form_state
->setErrorByName("translations][{$langcode}][{$key}", $this
->t('The submitted string contains disallowed HTML: %string', array(
'%string' => $value,
)));
$this
->logger('locale')
->warning('Attempted submission of a translation string with disallowed HTML: %string', array(
'%string' => $value,
));
}
}
}
}