I installed the explainfield module, and created some radio button explainfield items.
The usage I wanted was A radio button set that asked "Do you have kids?" with answers of 1|Yes or 0|No. If the user selected "Yes" I wanted them to have to enter "How Many" in the explainfield textbox.
When editing the node, however, The Yes and No radio buttons appeared, but no "other" box. When I selected the "Yes" item (the trigger key), and submitted the form, it threw an error saying "Please fill the optional form in Stepkids if you select this option."
Unfortunately, at no time did the text box actually appear, neither on the initial edit of the page, or after the page was submitted.
(Also, the error message does not indicate which optional form field needed to be filled out, which could be a problem if there is more than one explainfield item - but that's a seperate issue.)
So, basically what happens is that if I have an explainfield item, and the user selects the option requiring that they need to fill out additional information, all that happens is that they are unable to successfully submit the node add/edit form at all.
Comments
Comment #1
snufkin commentedthis sounds very bad. i tried to reproduce, but failed. i did the following to try it:
- downloaded the tarball, installed the module (i did not try the cvs version for this issue)
- created the widget the same way you explained
- created the content, entered the values (chose yes, entered data for the explain field). submit worked fine
- when editing the explainfield appears, containing the value i gave it.
is there any other way i could reproduce the bug? What browser did you use (i dont think this is browser issue, but just to be sure).
what i thought might be the case: What key did you select? in the expample you gave you should chose either 0 or 1, but if this is wrong the widget settings page should've thrown error...
Comment #2
Coyote commentedI've tried this with FireFox, Mozilla, and Safari.
I've tried selecting both keys to see what would happen.
If I don't use the trigger key, the page saves.
If I use the trigger key, the explain field doesn't appear, and since I've selected the trigger key, the page will not validate.
So, the only possible option for the user, in this case, is to select "No" (0)
If they select "Yes" (1), they are given no field in which to enter how many, and if they click submit anyway, they get a validation error message.
Comment #3
snufkin commentedI can not reproduce this bug. I tried the process as you described, and the explain field appears as it should. I tried:
a) adding key|label pairs like this:
Here the keys are 0 or 1. Not specifying the trigger key, or writing yes as trigger key does not validate as it should, and for 0 it validates, field is shown on the create node page.
b) adding only key:
in this case the trigger key would be 'yes', which validates, and again the textfield appears.
I will not close this issue, but since i can not reproduce this bug i won't pay more attention unless someone else can confirm its existence.
Comment #4
aasarava commentedI can verify that the problem exists, at least in some cases. In my case, I'm using the subform element module to include one form as part of a larger form.
In analyzing the generated HTML markup for the page containing the radios w/ explainfield, I see that the "name" for each radio is in this form: nodetype_node_form[fieldname][key]
But the explainfield module assumes that it can access the radios via fieldname[key] -- i.e., without the nodetype prepended. So if there is a nodetype, then the Javascript stops working because the jQuery selector doesn't match anything.
I've made a quick fix by changing lines 331 and 335 of explainfield.module to explicitly add the nodetype into the selector, like so:
But I'm not sure if this will break the explainfield for radios on other forms, where subform element is not being used. Snufkin, any thoughts? Ideally, the radios would use a more specific ID selector, the same way it does for checkboxes and other elements, so that it wouldn't matter what the "name" of the radio element was. Is it possible to do that?
Comment #5
snufkin commentedthanks for tracing the problem further, i really needed some more information on this bug. I will check if we can solve it with some more generic jQuery when I have some time. thanks again.