Context
Spin-off from #1992138: Helper issue for "field types as TypedData Plugins" / #1969728: Implement Field API "field types" as TypedData Plugins.
That issue adds actual validation on entity fields.
This means that implicit or explicit constraints contained in FieldItem::getPropertyDefinitions() (e.g 'type' => 'uri' in LinkItem, 'type' => 'integer' for 'tid' in TaxonomyTermReferenceItem...) that were just "dormant" so far in HEAD, are now fired.
This shows a couple problems, I'll open separate issues for them.
Issue
The "auto create / freetagging" feature of the autocomplete widgets (for entity_reference or taxo fields) break the constraint on 'target_id' / 'tid' being of type 'integer', because the items created by the "auto create" flow end up with a 'target_id' / 'tid' = FALSE, which is not an integer.
Patches coming up.
Comments
Comment #1
yched commented- "FAIL" patch adds a mock validation step in EntityFormController to demonstrate the buggy behavior when validation is actually performed. This should fail.
- "PASS" adds a proposed fix (standardize on '0' instead of FALSE to indicate "new entity being created"). This should pass.
- "FIX-ONLY" is just the fix, without the mock validate() calls. This should pass, and is the candidate patch to commit to HEAD.
Comment #2
yched commentedOops, warnings in the "mock validation code". Updated version of the "PASS" patch.
Comment #4
yched commentedSo, ok:
- the "PASS" patch still has many fails despite including the fix for this issue, because triggering constraint validation causes a lot more stuff than just constraints on target_id / tid.
- in the fix, the taxonomy formatters need to be adjusted accordingly
New patches:
- the "VALIDATE" patch adds a mock validation step in EntityFormController to demonstrate the buggy behavior when validation is actually performed. This should fail.
- the "VALIDATE+FIX" patch adds a proposed fix (standardize on '0' instead of FALSE to indicate "new entity being created"). This still fails, but with less fails :-)
- the "FIX-ONLY" patch is just the fix, without the mock validate() calls. This should pass, and is the candidate patch to commit to HEAD.
Comment #5
yched commentedTagging
Comment #6
berdir@yched: Note that all issues also need the Entity Field API tag to show up at http://entity.worldempire.ch/conversions
Comment #7
amateescu commentedGiven that tests will come naturally when #1969728: Implement Field API "field types" as TypedData Plugins gets in and we'll actually use the constraints, I think it's fair to get this one committed before.
Comment #8
amateescu commentedRestoring tags..
Comment #9
alexpottThis fix seems incomplete now all new values are 0 which is a int... what if the value being set is a string?
Comment #10
yched commented@alexpott not sure what you mean. There should not be a case where 'target_id' gets assigned as a string.
Comment #11
alexpott@yched oh - yep ingore me...
Comment #12
alexpottCommitted d3d704e and pushed to 8.x. Thanks!
Comment #13.0
(not verified) commentedAdd structure