Scenario:
1) Create an unlimited value field collection with a date (start end) and entity reference (all required fields).
2) Tried to test validation with single item in collection. Element in collection is properly validated with various combinations of partial dates and missing entity reference and validation holds.
3) Saved node, then edited to add another element to collection.
4) Second element I only filled in the entity reference field but left the date empty, submitted the and node saved without any error for missing date.
5) Node appears with incomplete date field but with the entity reference, despite both field being required in the collection.
If a partial date is added to the date field on second element, the date is validated properly, but the actual required aspect of the field is ignored.
I tried this with latest dev as well and found the same problem.
Comments
Comment #1
sgb9809 CreditAttribution: sgb9809 commentedAnyone have any ideas about this?
Comment #2
sgb9809 CreditAttribution: sgb9809 commentedFor anyone interested, I have gotten around the issue of having a field collection validate a required date - used Field Validation with custom PHP and field API for error. The normal required validation from Field Validation does not work.
Comment #3
mibfire CreditAttribution: mibfire commentedI am interested in, plz write here the solution. thx
Comment #4
mchaplin CreditAttribution: mchaplin commentedsgb9809 do you mean you used the field_validation module + a 'php code' validation rule + 'Set errors using field API' checkbox?
Comment #5
mchaplin CreditAttribution: mchaplin commentedIn the end I solved this with:
1) Custom form level validation (added via after build).
2) In that validation I check the value of the errant component of the field collection in $form_state (excluding the 0th value which is validated correctly).
3) Set the desired form errors using the code here:
http://api.drupal.org/comment/28464#comment-28464
Comment #6
mchaplin CreditAttribution: mchaplin commentedIs this a duplicate of http://drupal.org/node/1289062 ?
Comment #7
yuriy.babenko CreditAttribution: yuriy.babenko commentedConfirming as duplicate of #1289062: Required fields in collection not validated when empty.