Just a quick question. Is there a way to validate the max length of a "select or other" selection made using the "select or other module". Doesn't seem possible, but maybe I'm missing something.

Comments

svendecabooter’s picture

Assigned: Unassigned » svendecabooter
Category: support » feature
Status: Active » Needs work

Yes you could change the default settings in your custom module, by using hook_webform_validator_alter, like this:

function mymodule_webform_validator_alter(&$validators) {
  $validators['max_length']['component_types'][] = 'select_or_other';
}

This assumes the internal component type name for a Select (or other) webform component is in fact 'select_or_other'.
I might add this component to the default settings after I tested that module's webform component in some detail.

svendecabooter’s picture

Actually the above doesn't make sense.
The select or other module just adds extra functionality on top of the "select" component, so all validation rules that work for that component, will work with Select or Other as well.

The max length validator doesn't work with select components, because we assume that the options in the select component are defined by an administrator, so these shouldn't be validated, as there is no end-user input.
Of course if you add the "Select or Other" module end-user input becomes possible...

I have now added support for the Select (or Other) module, so what you are trying to achieve will now be possible with the latest code

svendecabooter’s picture

Component: User interface » Validation rules
Assigned: svendecabooter » Unassigned
Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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

NWOM’s picture

Awesome! Thank you for the help.