1

I have a project I'm working on where each content manager/author would have a different set of allowed values on a select input for each node created. Is hook_form_alter the best method for me to dynamically generate the options? And what would the syntax kind of look like?

0
0

You might get it to work like so:

  • Use the Select (or other) module, and
  • Integrate it in a form or module using a Forms API element.

More details below ...

About this module

Here is an excerpt about the Select (or other) module from its project page.

Provides a new Forms API element which is a select/radios/checkboxes element that has an 'other' option. When 'other' is selected a textfield appears for the user to provide a custom value.

So basically you could "start" from a few options (Option 1, Option 2, Option 3), and whenever somebody needs another one (not in the list yet), they just enter "Option 4". Here is a sample about it:

enter image description here

Integration in a form or module

By only using the module as delivered, you wouldn't have a different set of options yet for each author. But the Select (or other) module can be integrated in any form or module, as shown also in the usage example within the Community Documentation of this module.

By enhancing that usage example to make the values for value_1, value_2, value_3 depend on each user, you should get it to work.

Not the answer you're looking for? Browse other questions tagged or ask your own question.