1

In a custom module which I'm working on, I have a select list which currently has a hard-coded array of key=>value which could change and I would like to expose these options to the user.

I would like to be able to have a select form element which contains one textfield for the user to enter the ID of the option and another for the user to enter the value of the option. I could make a separate form for these options, but I'd like to keep all the configurations on one page since there aren't too many.

Does anyone know how I can make a select form element where the key and value of each option is keyed in by the user?

1

Do you know of Drupal's core field type "List" or what it's called and its "Allowed Values" field? Where admins can enter key|value pairs divided by a pipe character?

It's exactly what you seem to describe.

I'd start by mimicking exactly that. But all in one form. Maybe multi-step. Maybe peppered with some Ajax...

  • Thanks! This seems right, but I decided not to pursue it, as the functionality wasn't worth the effort in the end. – Travis Dec 6 '18 at 16:52

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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