3

I have a couple term reference fields, one of which allows unlimited values, and one of which allows 4 values. I'm using Simple Hierarchichal Select as the widget for the unlimited one, and it lets the user select a first value, and then click 'add another item' if they need more.

If I set the other value to a simple hierarchical select widget, it shows 4 rows with no Add another button. This makes sense, but encourages the wrong behavior for this case -- I'd prefer the user select only one value, but if they need to they can add up to 4. Having 4 rows from the beginning encourages them to add 4.

I would slightly prefer to use a select list widget for this limited field, but I don't feel confident that users are comfortable with the ctrl-click to select multiple items operation, so I'd prefer a dropdown allowing them to select one at a time, with an add more button. SHS would be fine too, if I could get it to show the 'add another another item' instead of showing 4 rows from the beginning.

Is either of those operations possible? Basically I want some kind fo dropdown widget, that allows users to select one value, and require them to click add another item, to add more, up to 4.

0

You can do it using Field Collection module

Once enabled, go to your content type and add a new field of Type: Field Collection and set to 4 values.

Then go to /admin/structure/field-collections and click on manage fields and add your select list field here and set value to 1.

Result:

enter image description here

If you don't want to allow users to set the same value, then you will need to use jQuery to hide value "X" in the 2nd drop down if the 1st drop down is set to value "X"

  • Thank you. For this project at this stage, adding field collections to the field is too much extra complexity for too little gain. If that is the only way to do it I'll do without it for now. – UltraBob Sep 3 '16 at 7:38

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.