diff --git a/core/modules/system/src/Tests/Entity/EntityValidationTest.php b/core/modules/system/src/Tests/Entity/EntityValidationTest.php index ef42036..6061acb 100644 --- a/core/modules/system/src/Tests/Entity/EntityValidationTest.php +++ b/core/modules/system/src/Tests/Entity/EntityValidationTest.php @@ -116,6 +116,7 @@ protected function checkValidation($entity_type) { // This should fail on AllowedValues and Length constraints. $this->assertEqual($violations->count(), 2, 'Validation failed.'); $this->assertEqual($violations[0]->getMessage(), t('This value is too long. It should have %limit characters or less.', array('%limit' => '12'))); + $this->assertEqual($violations[1]->getMessage(), t('The value you selected is not a valid choice.')); $test_entity = clone $entity; $test_entity->type->value = NULL; diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php index ab32c82..033731f 100644 --- a/core/modules/user/src/AccountForm.php +++ b/core/modules/user/src/AccountForm.php @@ -364,6 +364,8 @@ public function buildEntity(array $form, FormStateInterface $form_state) { /** @var \Drupal\user\UserInterface $account */ $account = parent::buildEntity($form, $form_state); + // Take care of mapping signature form element values as their structure + // does not directly match the field structure. $signature = $form_state->getValue('signature'); $account->setSignature($signature['value']); $account->setSignatureFormat($signature['format']); @@ -386,7 +388,8 @@ public function validate(array $form, FormStateInterface $form_state) { /** @var \Drupal\user\UserInterface $account */ $account = $this->buildEntity($form, $form_state); // Customly trigger validation of manually added fields and add in - // violations. + // violations. This is necessary as entity form displays only invoke entity + // validation for fields contained in the display. $field_names = array( 'name', 'mail', diff --git a/core/modules/user/src/Entity/User.php b/core/modules/user/src/Entity/User.php index 8af4db2..8be2e5e 100644 --- a/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -598,6 +598,7 @@ protected function getRoleStorage() { * Defines allowed signature formats for the field's AllowedValues constraint. * * @return string[] + * The allowed values. */ public static function getAllowedSignatureFormats() { if (\Drupal::moduleHandler()->moduleExists('filter')) { @@ -611,6 +612,7 @@ public static function getAllowedSignatureFormats() { * Defines allowed timezones for the field's AllowedValues constraint. * * @return string[] + * The allowed values. */ public static function getAllowedTimezones() { return array_keys(system_time_zones()); @@ -620,6 +622,7 @@ public static function getAllowedTimezones() { * Defines allowed configurable language codes for AllowedValues constraints. * * @return string[] + * The allowed values. */ public static function getAllowedConfigurableLanguageCodes() { return array_keys(\Drupal::languageManager()->getLanguages(LanguageInterface::STATE_CONFIGURABLE));