Closed (outdated)
Project:
Conditional Fields
Version:
6.x-2.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
30 Sep 2010 at 13:50 UTC
Updated:
30 Mar 2016 at 21:33 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
peterpoe commentedI tested this case in 6.x-2.x-dev and it works as expected: only the first value is required. Please, try to switch to the dev version, or wait for beta2.
Comment #2
drupalnesia commentedOn beta2 a non-core CCK Required field fail. My test:
1. Radio Button --> controller
2. Filefield to Upload Photo --> controlled, marked as Required field
Even CF can hide Filefield but when press Submit says: 'Upload Photo is required'!
Comment #3
manuel.adanHi there,
Just another issue thats might be related to this. My config:
- integer radio field as a controller
- embeded media video field as controlled (required)
no other cck fields. When video (controlled) field is hidden, node form submits right, but when it is shown, I got a required field error message when submit, even when a value is entered in video field.
Comment #4
manuel.adanEmbed media field related issue is specific to this type of fields. conditional_fields_check_empty function tries to check empty values on any kind of field, but many of existing field modules have their own empty conditions. Module should use hook_content_is_empty() for this purpose.
Attached patch solves the issue for embed media fields.
Comment #5
carvalhar commentedhi
i'm having the same kind of issue.
My controlled field is a content taxonomy (with hierarchical select widget), it's required if the controller value is selected.
But even with other value selected, the hidden controlled field is being required, making impossible to save the node.
how should i solve this?
thanks
Comment #6
yannickoo@carvalhar can you type
print_r($field);on line 989 (after thefunction conditional_fields_check_empty($field) {).You should get an array which contains one item. Post a screenshot or just the output please.
I created a new patch which adds support for media embed fields and link fields.
Comment #7
roball commentedThis problem is also in the 2.0 final, right?
Comment #8
yannickoo@roball, I think so.
I attached a path which contains support for user references fields. Can anybody tell me the key of the value field from content taxonomy? So that we can add them in the patch?
Comment #9
yannickooOh, there is an error with emfield fields because there also has a value key ('embed' => 'http://youtube.com/watch....', 'value' => '').
My quick and dirty check is:
Comment #10
peterpoe commentedTo my embarrassment I discovered, after years of CCK hacking, that fields usually implement hook_content_is_empty to determine if the field has any value, so I rewrote conditional_fields_check_empty to take advantage of this feature (and renamed it to conditional_fields_is_empty for consistency).
Moreover, I found that some modules, like filefield, use the $form['#field_info'][FIELD_NAME]['required'] property to determine if a field is required, and not $form[FIELD_NAME]['#required'], so I updated conditional_fields_custom_required_field() to take this into account.
The new approach solves the required fields problem with all implementations except those that add extra validation logic ignoring the required property, like the Link module, which is, in my opinion, a bug on their part.
The change is already committed, thanks for the efforts everyone.
Comment #11
kbk commentedFixed in dev, if I am correct.
Comment #12
roball commentedBut the selected version is usually the latest release having the bug, not that with the bug fixed.
Comment #13
peterpoe commentedThe selected version should be the one to which the patch applies, but I have a bad habit of not waiting for reviews on the patches that I write, so there is no patch here. I think that in this case the right version === undefined.
Comment #14
kbk commentedI've tried out 6.x-2.x-dev (Feb 3, 2012) and there is something wrong. I now have hidden, required node reference fields that halt form submission if they are empty. This should probably be a new issue but the latest dev breaks my form.
Comment #15
peterpoe commentedNode reference fields work fine for me. Can you provide an export of the content type?
Comment #16
xaqroxI posted issue #1483994: Calls to hook_content_is_empty should provide single item as first argument., and after much investigation, traced it back to changes introduced by the commit referenced in comment #10 (http://drupalcode.org/project/conditional_fields.git/commit/25e00b9572a0...).
conditional_fields_is_empty()sends the item array to the implementations ofhook_content_is_empty()it finds, but every implementation of that hook (that I could find) expects a single item. My fix was to use$item[0]instead of$itemin the call to the hook, but my intuition suggests thatconditional_fields_is_empty()should expect a single item to maintain the convention established byhook_content_is_empty(). On the other hand, this isn't actually an implementation of that hook, so maybe not.(BTW, following @peterpoe's suggestion "The selected version should be the one to which the patch applies" in #13, I've changed the version to 6.x-2.x-dev.)
Comment #17
leo pitt commentedThe patch at #16 fixes the issue for me.
Comment #18
roball commentedThis issue is really critical because the current 6.x-2.x-dev won't work with required fields (6.x-2.0 did work). Can also confirm that the small and simple patch from #16 solves this issue. Can you please commit? Thanks.
This bug has also been discussed at #1515844: "[fieldname] field is required" error even though I entered data for that field .
Comment #19
tajindersingh commentedPatch #16 fixes it.
Sometimes it takes a lot of time to trace the culprit.
Please commit it. Thanks
Comment #20
dchatry#16 works for me too, can you commit it ?
It's a pretty big issue for those still using D6...
Comment #21
drenton commented#16 works for me too.
Comment #22
peterpoe commented