Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
When controlling a field which is required and has unlimited value, all the value fields must be filled in order to validate.
When usually without this module the first value field is required but the second and third are options.
Example:
Telephone *
FIELD 1
FIELD 2
FIELD 3
Only Field 1 is required without Condional Fields module.
When activating a field to control the telephone field all 3 fields becomes required when only 1 should actually be.
Warm regards,
webadpro
Comment | File | Size | Author |
---|---|---|---|
#16 | conditional_fields-item0_empty-927558-16-D6.patch | 537 bytes | xaqrox |
#8 | conditional_fields_more_validators.patch | 621 bytes | yannickoo |
#6 | conditional_fields_more_validators.patch | 515 bytes | yannickoo |
#4 | required_mediaembed_fields_emptyvalue_check.patch | 893 bytes | manuel.adan |
Comments
Comment #1
peterpoe CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: kbk commentedFixed in dev, if I am correct.
Comment #12
roball CreditAttribution: roball commentedBut the selected version is usually the latest release having the bug, not that with the bug fixed.
Comment #13
peterpoe CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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$item
in 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 CreditAttribution: Leo Pitt commentedThe patch at #16 fixes the issue for me.
Comment #18
roball CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: drenton commented#16 works for me too.
Comment #22
peterpoe CreditAttribution: peterpoe as a volunteer commented