Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

How to limit selection on Multi select form Field

I am trying to limit the total number of items that can be selected on the $has_many multiselect form field, the user guide don't seem to provide a way to this. is there parameter for such feature like LIMIT on multi select form field.
$fields['multi_example'] = array('type' => 'multi', 'options' => $options, 'value' => 'a' , 'limit'=> some value);

Comments

  • There currently is not such an option to limit the selection.

  • What other approach can i use to achieve this. i have tried to inserd the disabled= true and readonly = true, attribute to the multiselect using javascript but it did not work.

    i want to disable selection once a user select a cirtain number of item

  • if it was me, I'd create a new custom field based on the multi field type and add javascript to count the selections on each change.
    Maybe there's already a similar selection widget out there that does that? Perhaps incorporate that as a custom field?

  • i tried that, the problem is that it wont just disable by adding the attribute disabled=yes or readonly= yes. they dont have effect on it.
    secondly it is suppose to be a has_many hook so i am not sure i can do that with custom field

Sign In or Register to comment.