Loading core/lib/Drupal/Core/Form/FormValidator.php +6 −0 Original line number Diff line number Diff line Loading @@ -345,6 +345,12 @@ protected function performRequiredValidation(&$elements, FormStateInterface &$fo if (is_array($elements['#value'])) { $value = in_array($elements['#type'], ['checkboxes', 'tableselect']) ? array_keys($elements['#value']) : $elements['#value']; foreach ($value as $v) { if (!is_scalar($v)) { $message_arguments['%type'] = gettype($v); $form_state->setError($elements, $this->t('The submitted value type %type in the %name element is not allowed.', $message_arguments)); $this->logger->error('The submitted value type %type in the %name element is not allowed.', $message_arguments); continue; } if (!isset($options[$v])) { $message_arguments['%choice'] = $v; $form_state->setError($elements, $this->t('The submitted value %choice in the %name element is not allowed.', $message_arguments)); Loading core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php +13 −0 Original line number Diff line number Diff line Loading @@ -462,6 +462,19 @@ public static function providerTestPerformRequiredValidation() { 'Test cannot be longer than <em class="placeholder">7</em> characters but is currently <em class="placeholder">8</em> characters long.', FALSE, ], [ [ '#type' => 'select', '#options' => [ 'foo' => 'Foo', 'bar' => 'Bar', ], '#value' => [[]], '#multiple' => TRUE, ], 'The submitted value type <em class="placeholder">array</em> in the <em class="placeholder">Test</em> element is not allowed.', TRUE, ], ]; } Loading Loading
core/lib/Drupal/Core/Form/FormValidator.php +6 −0 Original line number Diff line number Diff line Loading @@ -345,6 +345,12 @@ protected function performRequiredValidation(&$elements, FormStateInterface &$fo if (is_array($elements['#value'])) { $value = in_array($elements['#type'], ['checkboxes', 'tableselect']) ? array_keys($elements['#value']) : $elements['#value']; foreach ($value as $v) { if (!is_scalar($v)) { $message_arguments['%type'] = gettype($v); $form_state->setError($elements, $this->t('The submitted value type %type in the %name element is not allowed.', $message_arguments)); $this->logger->error('The submitted value type %type in the %name element is not allowed.', $message_arguments); continue; } if (!isset($options[$v])) { $message_arguments['%choice'] = $v; $form_state->setError($elements, $this->t('The submitted value %choice in the %name element is not allowed.', $message_arguments)); Loading
core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php +13 −0 Original line number Diff line number Diff line Loading @@ -462,6 +462,19 @@ public static function providerTestPerformRequiredValidation() { 'Test cannot be longer than <em class="placeholder">7</em> characters but is currently <em class="placeholder">8</em> characters long.', FALSE, ], [ [ '#type' => 'select', '#options' => [ 'foo' => 'Foo', 'bar' => 'Bar', ], '#value' => [[]], '#multiple' => TRUE, ], 'The submitted value type <em class="placeholder">array</em> in the <em class="placeholder">Test</em> element is not allowed.', TRUE, ], ]; } Loading