Hi,
I have a content type that contains 3 fields:
- Field A: a select list with two values V1, V2
- Field B: a text field declared as required
- Field C: a field collection
Field B is only visible if Field A value is V2 (dependency declared thanks to conditional fields).
If I try to submit a new content with Field A = V1 (then Field B is not visible), the form is submit with no error but Field C is not saved. It is logic because the field collection is saved only if there is no error in the form (code in field_collection_field_widget_embed_validate function). But, since the Field B is required, then an error is declared. This error is handled/cleared by conditional_fields_form_validate but it is called after all the other hooks (thanks to conditional_fields_module_implements_alter).
I don't know where we should fix the issue: in field collection module or in conditional fields...
What do you think ?
Comments
Comment #1
RyanPrice commentedI second the issue experienced here, my field collection values are not being saved and the functionality of my content type would mirror rfc2460's above.
Comment #2
dufferin commentedSame, here,
For ex : I have one group of fields, with conditional field. I'm using field collection as well.
When the dependee has value, the dependent (field collection) is visible.
On node/add or edit, If I add a value to the dependee, the dependent shows off. I fill up the fields. Save.
And what exactly happen is that the dependent fields keep their values, but the dependee don't, then values (dependent field collection) won't display on the node.
By the way the 'field collection' label and content won't display either.
But is it due to 'field group', 'conditional field' or 'field collection', or just the all don't play nice together...?
Update : because I'm on it right now, I see that removing a 'conditional field' make the values (previously dependent) shows up. So definitely a problem with 'conditional field' and 'field collection'.
Here is the error msg I get : Notice : Undefined index: und dans conditional_fields_evaluate_dependencies() (ligne 1020 dans /Applications/MAMP/htdocs/immobilier/sites/all/modules/conditional_fields/conditional_fields.module).
Comment #3
rfc2460 commentedhi,
I now think that the issue is in the field collection module.
In function field_collection_field_widget_embed_validate of field_collection module (see code snippet below), it tests if there are errors in the form and not only the error coming from the validation of the field collection field. As we can have errors coming from required field hidden using conditional field, then the field collection is not saved. The trick is that conditional field module will manage (and clean) the errors relative to the dependents or the dependees but it is called at the end of the form validation process (in the function: conditional_fields_dependent_validate).
So I rewrite this function in order to check only the errors coming from the field collection validation. I'm really sorry but I am not familiar with the patch process and I unfortunatly do not have time today to create a nice patch so here is the code I use now (and that solves my problem...)
I will suggest a patch in the field condition module as soon as I have time (hopefully before the end of the week).
I close the ticket since it is not due to conditional field. Please follow #1549364: Data not being saved on initial creation for the patch.
@dufferin I am not sure your problem is identical to my issue, I suggest you create a new ticket for that.