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

sgb9809’s picture

Anyone have any ideas about this?

sgb9809’s picture

For 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.

mibfire’s picture

I am interested in, plz write here the solution. thx

mchaplin’s picture

sgb9809 do you mean you used the field_validation module + a 'php code' validation rule + 'Set errors using field API' checkbox?

mchaplin’s picture

In 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

mchaplin’s picture

Is this a duplicate of http://drupal.org/node/1289062 ?

yuriy.babenko’s picture

Status: Active » Closed (duplicate)