commit 5f5782e89ea9078ba0a75baef3990f811b8aa5f3 Author: Yves Chedemois Date: Wed Jun 5 14:54:06 2013 +0200 fix validation errors on autocomplete widgets (e_r, taxo) diff --git a/core/lib/Drupal/Core/Entity/Field/Type/EntityWrapper.php b/core/lib/Drupal/Core/Entity/Field/Type/EntityWrapper.php index e99187b..c819ead 100644 --- a/core/lib/Drupal/Core/Entity/Field/Type/EntityWrapper.php +++ b/core/lib/Drupal/Core/Entity/Field/Type/EntityWrapper.php @@ -90,7 +90,7 @@ public function setValue($value, $notify = TRUE) { if ($value instanceof EntityInterface && $value->isNew()) { $this->newEntity = $value; $this->entityType = $value->entityType(); - $value = FALSE; + $value = 0; } elseif ($value instanceof EntityInterface) { $this->entityType = $value->entityType(); diff --git a/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyCField.php b/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyCField.php index f788609..dcd5d93 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyCField.php +++ b/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyCField.php @@ -56,21 +56,9 @@ public function prepareCache() { /** * {@inheritdoc} - * - * @todo Other possible approach: implement getConstraints() and use a - * dedicated LegacyFieldConstraint class. */ public function validate() { - // Do not validate base constraints for entity_reference items for now (the - // autocomplete widget receives 'target_id' as a string). - // @todo Remove the special case when http://drupal.org/node/2007422 is - // fixed. - if ($this->getPluginId() == 'field_type:entity_reference') { - $violations = new ConstraintViolationList(); - } - else { - $violations = parent::validate(); - } + $violations = parent::validate(); // Filter out empty items (legacy hook_field_validate() implementations // used to receive pruned items). diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php index 7ceb350..01a01fa 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php @@ -97,7 +97,7 @@ public function massageFormValues(array $values, array $form, array &$form_state 'vid' => $vocabulary->id(), 'name' => $value, )); - $item = array('tid' => FALSE, 'entity' => $term); + $item = array('tid' => 0, 'entity' => $term); } $items[] = $item; }