With the latest 7.x-2.x-dev code I'm getting the following error on a select_or_other_buttons field:
Notice: Undefined index: option in theme_select_or_other_none() (line 250 of /sites/all/modules/contrib/select_or_other/select_or_other.module).
The field has the following settings:
- Required: checked
- Available options: multiple items listed.
- Available options PHP: empty
- Other value as default value: ignore the values
- Sort options: unchecked
- Number of values: 1
Tracing through the code it seems that the following is incorrect:
$multiple = !(($instance['widget']['type'] == 'select_or_other_buttons' && $field['cardinality'] == -1)
|| ($instance['widget']['type'] == 'select_or_other' && $field['cardinality'] == -1)
|| ($instance['widget']['type'] == 'select_or_other_sort'));
This appears to be trying to identify whether this is a field set to allow multiple values, but it then negates the boolean answer and with my example it ends up saying $multiple == TRUE, which it isn't.
Comments
Comment #1
damienmckennaHere's a patch to remove the "!" from the line above (it also tweaks the comments a little bit), but I'm not sure the logic around this portion of the function is correct, it might need some further review.
Comment #2
damienmckennaThe error still showed in certain cases, so I've updated the patch to change the theme function a little as that $variables['option'] variable doesn't exist in all cases.
Comment #3
damienmckennaComment #4
danielb commentedThanks, I've committed and made a new release because that's a big screw up.
Comment #5
damienmckennaI accidentally missed a line from the last patch, sorry.
Comment #6
danielb commentedcheers
Comment #8
let-1 commentedWhen I use "text" for type of data to store and "Select (or other) check boxes/radio buttons" for Widget, I'm getting a checkbox with a blank label now.
The field has the following settings:
Required field: checked
Available options: multiple items listed.
Available option:
test 1
test 2
test 3
test 4
Other option: Other
Other value as default value: Add the values to the other textfield
Sort options: unchecked
Number of values: Unlimited
Comment #9
puddyglumI had the same issue as let. The previous patch forgot to add an if(!$required) check to the select_or_other_buttons widget (even though the Comment said otherwise).
Adding this patch fixed it for me.
Comment #10
puddyglumCan somebody review the above patch? Without the patch, a Multiple value checklist field that is required will get the "N/A" option, which should only appear on Optional fields.
Comment #11
danielb commentedSeems reasonable to me, but I haven't used it. I can add the change manually as the patch contains non-drupal coding style.
Perhaps wait a little while to see what others might say.
Comment #12
puddyglumFixed the coding a little
Comment #13
danielb commentedcheers
Comment #14
r.renwick commentedis there a consensus on this? i am having the same issue, with the N/A box appearing when used as a field widget and i cannot get rid of it.
Comment #15
iancm commentedI've got the same problem now where the option 'N/A' is showing up on the form if it's a field widget and it's not required. If I checked required the 'N/A' still shows in the list for default values in the backend but it doesn't appear on the user form.
Comment #16
danielb commentedComment #17
danielb commented@ #14 & #15; I have carefully considered what you said and checked the module, and there is nothing in what you said or what I see in the module to suggest the module continues to work incorrectly in regards to this issue. In fact what iancm described is precisely the intended behaviour. The N/A option will appear when there is no default value. If you do not choose a value and attempt to submit the form you will receive a validation error. You get rid of the N/A by selecting a value and submitting the form.
I don't believe this behaviour was specifically innovated for select_or_other and probably copied from another module.
Comment #18
iancm commented@danielb so there's basically no way to have a answer blank and not have a 'N/A' in the list?
I just want to create a question that has the other option. The question is not required and therefore the n/a option doesn't need to be listed. I have several that are yes/no and if yes then I want the text field. These are not required but when these are viewed I get:
o N/A
o No
o Yes -> other field
If this is the intended use that I guess I'll just have to write some custom css or js to hide all these options for non required fields.
*I now understand that this is a core field way to radio buttons and 'not required' fields. I'll look more into the core community for answers. Thanks for your time.
Comment #19
puddyglumiancm, when our team started using this module we were split on the "N/A" option for optional fields. Some thought N/A was necessary but others didn't like it. But we found that removing the N/A option on optional fields makes the form less accessible. If a user clicks "No" or "Yes", but then wants to undo their choice and select neither, they can't. Hence the "N/A" option, which allows them to basically select neither option. Without it, the optional field really becomes "Required".
One resolution to this might be to add a Javascript link which says, "Clear my selection". If Javascript is disabled, "N/A" appears. If Javascript is enabled, it replaced "N/A" with "Clear my selection". That in my opinion would be a great feature...
Comment #20
samdeskin commented@danielb in #17 you say:
But even if you select a Default Value N/A appears.
I believe that if a field is a "Required Field" N/A should not appear unless we add it to the "Available Options"
Comment #21
samdeskin commentedNevermind, figured it out.
Have to update here:
Home » Administration » Store » Configuration » Line item types »