A few of the node types on my site have a controlling field ( a tickbox) which must be filled in. If the user ticks it, then a controlled field appears. This is a text field and also must be filled in.
Ideally, if the tickbox isn't ticked then I don't want an error message to be displayed due to the controlled field being left blank. This is what happens in two of the four occasions where this sort of setup is implemented on my node types. However, on the other two occasions Drupal complains that I haven't completed the controlled fields, even if they aren't visible.
Am I missing some setting, or is this a bug?
Comments
Comment #1
peterpoe commentedCould you please export your content type and fields definitions and send them so that I can test?
(We have import/export compatibility now! You have to update to the latest cvs to make import/export work)
Comment #2
jim0203 commentedYes:
http://drupalbin.com/9266
The four controlled fields are each called "Please specify". They are controlled by on/off tick boxes: if the box is checked, the field is shown.
Two of the tick boxes are called "other"; the other two start with the word "special". It's the fields that are controlled by fields called "Other" that are always being required, even if they are not visible. Interestingly, these fields are contained with field groups. The other fields, which work as I'd expected, are not contained within field groups.
Comment #3
matteogeco commentedWhat happens to me is:
Comment #4
peterpoe commentedThere was a wrong variable name on line 609. Patch provided. Also, committed to cvs since it is an easy fix. Thanks!
Comment #5
matteogeco commentedAsk for reopening the issue, after applying the patch I have this problem: I got some required fields inside a controlled group and they give error even if they are hidden.
Comment #6
peterpoe commented@matteogreco: could you please export the content definitions and add to drupalbin.org so that I can more easily test? Thanks.
Comment #7
matteogeco commentedHi peterpoe, thanks for the "live" support; here is my content type: http://drupalbin.com/9272, the controlling field is field_tipo_art_pn, it controls the group group_det_banc, the required fields are field_conto_corrente and field_num_assegno.
PS: I'm not matteogreco, but matteogeco, from the name of the company I work for. ;-)
Comment #8
matteogeco commentedWell done, kid! it seems to me that last dev version solves the problem, for me this issue could be closed.
Comment #9
peterpoe commentedOk matteog(
r)eco, I'll mark this as fixed. ;)Comment #11
leon85321 commentedHello,
I have just applied the latest dev version and i am having the same problem here for the required field inside a controlled field group.
I have required fields, FieldA, that is not controlled by anything outside of the field group, FieldGroupA, (well it is supposed to be this way i believe),
That FieldGroupA is controlled by a conditional text select field, ControlFieldA.
When I select any options from ControlFieldA that does not trigger FieldGroupA, it gives me error that FieldA is required but it is invisible due to FieldGroupA is not triggered.
Do you have a fix for this?
Thank you,
Leon
Comment #12
leon85321 commentedHello again,
I found a work around is to set a default value for that required field...
But maybe yo have a better way to solve it?
Thank you,
Leon
Comment #13
scottrigby@peterpoe: I installed the dev version, and i do not get an error when conditionally hidden fields are required. However, if the required field is a select list, the field values are not unset - they're still saved in the node object.
Comment #14
servantleader commentedI am using the latest dev version and this is still not working. Required fields are still causing errors of left blank. I have a simple checkbox that as controlling a field group that contains required text fields.
Comment #15
peterpoe commentedI have just committed a patch that fixes the issues with required fields reported by @leon85321 and @servantleader. There is still one issue remaining: required controlled fields inside a controlled fieldgroup still give the required error if they are left empty, triggered and the fieldgroup is not.
Comment #16
marc angles commentedI still have the issue here.
Using the last dev version.
The controlled fields are file_field, some option doesn't trigger any fiel_field but then the node isn't submitted because of these required fields. You can see in the content-type export here :
http://koumbit.pastebin.com/d12278597
Comment #17
urlisse commentedIt would appear that conditional fields won't work with some required CCK fields, such as filefield or imagefield.
After some enquiry, I found that the filefield module's hook_validate() implements its own way of checking for the #required property: it appears to be checking against the CCK field's required setting returned by the content_types() function. Because of this, it ignores the work done by the conditional fields module using hook_form_alter() and empty required fields will always fail validation, no matter what conditional field does to the form.
Comment #18
balintbrewsStill not working... but it would be great. What do you think? Is there any chance to fix it in the immediate future?
Comment #19
Bilmar commentedYes, I experimented with weight of modules but still experienced the issues mentioned above.
It would be great to be able to have this working with imagefield
Comment #20
cdale commentedDid the patch in #4 get reverted? Or is there now another typo which looks identical on line 654?
Comment #21
peterpoe commented#20: could you give more context? Patch in #4 has not been reverted.
Comment #22
peterpoe commented#18 Fixed in dev!
Comment #23
cdale commentedSorry. I misread the code. There is no type. :) I was looking at the wrong place.
Comment #24
peterpoe commentedOk cdale, this is good because I hate those required fields - when I have to fill them in the first place ;)
So I mark this as fixed, feel free to reopen if the required fields require some more attention.
Comment #25
aaronbaumanStill busted for me.
Here's my setup:
conditional_fields-6.x-1.x-dev
controlling field: text, radios widget*
2 allowed values: "Yes" and "No" (in that order).
required
controlled field: text, single line text widget
controlling value: "Yes"
required
* - i also tried "select" and "single checkbox". neither works.
perhaps worth noting: neither field is in a fieldgroup.
Then I noticed that the patch in #4 was NOT applied to dev.
So I patched it.
Still doesn't work.
Comment #26
smscotten commentedBusted *again* for me. It really had been fixed.
I reverted to 6.x-1.0-beta2 (2009-06-10) and this problem went away, but the problem was exhibited in both the current 6.x-1.0 (2009-Nov-28) and 6.x-1.x-dev (2009-Dec-06) versions.
Comment #27
igorik commentedHi
I can confirm this bug, my required fields (radios, I think date field too) are not required although it's controlfield is checked, and the node is stored with empty required fields.
Using latest conditional fields module 1.x.
Igor
Comment #28
samkat12 commentedConditional field is causing fields to be required even if they were not set up to be required. the situation is that when you place the controlling filed out side group and the cotrolled field in a group, the system does not allow you to save, it produces an error message that fields in group are required. even if the fields have been filled in. However there is no error if the controlled field is not triggered.
[...A..] controlling field out side Group
[...B...] Controlled field in a group. (produces an error message that the fields in the group are required to be filled in even if i have put data into them). Can any one help?
Comment #29
peterpoe commentedJust committed a fix to both 1.x and 2.x dev branches... Hope it will be the last!
Comment #30
Bilmar commentedthanks for your hard work peterpoe!
Comment #31
capellicI just discovered this module yesterday... and I was having problems with 1.1. Then I found this and it works perfectly... just in the nick of time. Thanks!
Comment #32
samkat12 commented6.x-2.x-dev works. my issue #28 is been solved. THANK YOU VERY MUCH FOR THE PROMPT RESPONSE TO THIS ISSUE
Comment #34
evanbarter commentedSorry for bumping an old issue, but I was wondering if the latest 2.x-dev (commit #352758) caused a regression here? I've got fields which are being conditionally hidden throwing validation errors.
Here's an export of the pertinent fields in my content type: http://drupalbin.com/14424
Comment #35
webflo commentedI have the issue. Tested with 1.x / 2.0 / 2.0-beta1 but there are always validation erorrs.
thx flo
Comment #36
jocken commentedHad the same issue but replaced checkboxes and radiobuttons to a list. Worked like a charm.
Comment #37
JThan commentedI get Validation errors on a required filed which is controlled. It is filled out but still the validationsays it needs to be filled. When I deactivate the controll for that field, the field validates as expected.
Updated to last dev, recreated all fields, testet with and without controll.
Edit: Changing the radio buttons to a List did not change anything.
Comment #38
evanbarter commentedIs there any chance we could get a resolution on this? I've taken a look at the commit history back to January and poked around the module but I can't figure out why it's currently broken.
Comment #39
evanbarter commentedWhoops! I may have been too hasty in bumping up the priority, sorry. I managed to trace my particular issue back to the Formatted Number (http://drupal.org/project/formatted_number) CCK type. While compatibility with this non-core widget would be appreciated, it certainly doesn't warrant critical priority. Hopefully this helps other people still experiencing difficulties.
Comment #40
BeaPower commentedStill doesnt work with dev version...
Comment #41
briand44 commentedI am using the dev version as well and am still having problems. I have a controlling field that is a select list and when a certain option is selected then the controlled field (which is radio buttons and required) appears. If I don't select the certain option then I get an error that says an illegal choice has been detected. If I change the controlled field to a select list it solves the problem. Is there anyway to fix this for radio buttons?
Comment #42
thekevinday commentedWhat happens is that drupal core does not understand that they need to support radio buttons that have no selected choice.
I have opened a bug report here: http://drupal.org/node/919348
Comment #43
scottrigby@thekevinday the D7 patch i made from your code in #919348: unset form values, such as radio buttons improperly trigger 'An illegal choice has been detected' passed unit testing (it didn't pass @ first until Damien Tournoud changed the version to 7.x-dev).
I literally used the code exactly as you suggested, because it looked good. And seems to work well for this issue.
see http://drupal.org/node/919348#comment-3746952
In the meantime, I've also made a D6 version of the patch for anyone here who needs it:
http://drupal.org/node/919348#comment-3746858
Comment #44
igorik commentedComment #45
BeaPower commentedAny fix for D6? Seems as if the patch failed...
Comment #46
kbk commentedThe patch mentioned in #43 worked for me although I can't comment on any further affects it may have on Drupal 6 core. Can anybody here?
Comment #47
inky@inky3d.com commentedThe patch has also worked for me. Have not come across any other issues from this (yet).
Comment #48
dontgoquietly commentedinky3d, did you test this on Drupal 6?
Comment #49
sketman commentedHello!
I have the same validation problem when content taxonomy field controlls the formatted integer number. Problem occurs only with formatted integer, integer seems to work fine.
I am using the latest 6.x-2.x-dev version, but it was the same with 6.x-2.0-beta2 and 6.x-1.1.
Any thoughts please?
Comment #50
drwierdo commentedIt seems there is this very problem also in the 7.x-dev version of this module...can we have a patch for that??
p.s. am i correct in posting this issue here?? Is it the right place??
Comment #51
peterpoe commented#50 7.x-dev did not support required fields at all until today. Please try the latest dev and open and another issue if you find problem with it.
Comment #52
fastdev commentedHello,
I have the same problem when a list controls a content taxonomy field. If I select an item in the list which does not trigger the content taxonomy field, I get a validation error.
I use Hierarchical Select as a widget for the content taxonomy field.
Do I need to do anything special to make it work ?
Comment #53
tejaspmehta commenteddoes anyone have solution for this ? If yes please post it.
Comment #54
peterpoe commentedThis issue should stay closed because it looks that there is no problem with basic CCK fields when they are required.
- If you have problems with fields/widgets provided by modules other from CCK, search the issue queue for issues with a "Compatibility w/ other modules" component, and if you don't find any, file a new one.
- For problems with Drupal core: sorry I can't help.