Need some help with your project? Contact me

Cool module: Select (or other)

Select (or other) let’s you provide an Other text field to a select list if the available options in this list do not contain what the user wants to select. It’s actually a pretty nifty module with quite a few options and its functionality can be used in multiple ways: you can use for content and webform fields and you can declare new instances in custom modules.

I’m sure at one point or another you’ve run into the situation. You needed a select list with fixed available options but more flexible to accommodate also for custom text choices. This is the module for you. So let’s see how to set it up as it’s not as obvious as I thought it was going to be.

After enabling the module you can go to the Manage Fields section of any content type and add a new text field. That’s right, there is no new field type nor is the new functionality attached to the select list field type. For the widget you have 3 new choices: Select (or other) check boxes/radio buttons, Select (or other) list and the deprecated Select (or other) drag and drop lists.

If you go with one of those, you will then have some configuration to do. It will be a combination of text field and list specific settings. After you specify what available options you would like in the select list, you have to configure the Other text field. This means specifying the label, title, field size and what to do with the value the user enters into the Other field.

The Other value as default value setting is quite interesting. The first option makes it that if the user fills in the Other field and saves the content, upon editing the content later, the Other field will be populated with that information. This is quite expected.

The second option will make it that the information specified in the Other field gets attached to the list of options. This means that when the user edits later the content, s/he will have the choice between the initial list of options + the information s/he provided into the Other field + a brand new Other field available as a choice.

The third option is similar to the second one apart from the fact that if one user fills the Other field for one piece of content, his/her choice will be added to the list of available options also for other users creating new content with that field attached.

The fourth option simply ignores the value a user enters into the Other field so that when editing later the content, the user will no longer see the choice s/he made in it.

A last thing that I want to mention about this module is that if you want to use this type of field in a custom module, you have an example here that illustrates the Field API declaration for this particular type.

Comments

Good article! Thank you! Choosing of needed module is not simple job. When I need some modules, I find it in collection of modules and view some examples of the websites that use it

I usually prefer "Not mentioned" instead of "Other". The reason is I found Not mentioned is more appropriate for an option than Other from grammatical point of view.

Great article Thank you. Saved a lot of time

Add new comment

You must have Javascript enabled to use this form.