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

damienmckenna’s picture

StatusFileSize
new1.47 KB

Here'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.

damienmckenna’s picture

StatusFileSize
new2.06 KB

The 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.

damienmckenna’s picture

Status: Active » Needs review
danielb’s picture

Category: support » bug
Status: Needs review » Fixed

Thanks, I've committed and made a new release because that's a big screw up.

damienmckenna’s picture

Status: Fixed » Needs review
StatusFileSize
new428 bytes

I accidentally missed a line from the last patch, sorry.

danielb’s picture

Status: Needs review » Fixed

cheers

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

let-1’s picture

StatusFileSize
new5.61 KB

When 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

puddyglum’s picture

StatusFileSize
new612 bytes

I 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.

puddyglum’s picture

Status: Closed (fixed) » Needs review

Can 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.

danielb’s picture

Seems 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.

puddyglum’s picture

StatusFileSize
new658 bytes

Fixed the coding a little

danielb’s picture

Status: Needs review » Fixed

cheers

r.renwick’s picture

is 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.

iancm’s picture

I'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.

danielb’s picture

Status: Fixed » Active
danielb’s picture

Status: Active » Closed (fixed)

@ #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.

iancm’s picture

@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.

puddyglum’s picture

iancm, 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...

samdeskin’s picture

@danielb in #17 you say:

The N/A option will appear when there is no default value.

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"

samdeskin’s picture

Nevermind, figured it out.

Have to update here:

Home » Administration » Store » Configuration » Line item types »

  • Commit 1bfb14e on 7.x-2.x, 7.x-3.x, 8.x-3.x by danielb:
    Issue #1324098 by DamienMcKenna: select_or_other_buttons widget adds 'n/...
  • Commit 3b9becc on 7.x-2.x, 7.x-3.x, 8.x-3.x by danielb:
    Issue #1324098 by DamienMcKenna: Removed line from theme function that...
  • Commit 3b0e755 on 7.x-2.x, 7.x-3.x, 8.x-3.x by danielb:
    Issue #1324098 by jmonkfish: None option should only appear on non-...