Change Dropdown field to multiselect field according to Category

Hello everyone,

I have a "Type" field as  dropdown and I want to change it multiselect field according to Category change. Please share your idea that how can I do it.

If category = specimen then Type field = multiselect.

If category = product then Type  field = dropdown.

Thanks

Laxmichand saini

  • Hello ,

    I don't think that it's safe to change the field type because the data consistency will be wrong in database.

    So, in my mind, you need

    • a dropdown field, visible if category = specimen
    • a multiselect field, visible if category = product
    • both fields used the same dropdown list
    • a "consolidated" multiselect field where the value is stored (using hook for instance) : so only one value if specimen, possibly many if product
      • this field will be used for reporting etc.

    best regards,

    Fred

  • You can not modify a field type on the fly, instead you can create a custom field type which extends from enum (the target field must be a multienum) and in its js controller you may decide whether to render additional options or not. Follow the example below:

    If field has a selected option and category is specimen: show all available remaining options

    If field has a selected option and category is product: do not show any other option

    If selected option has been removed from field: show all available options

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • You can do this in Studio you don't need to do any custom programming.

    Create a MultiSelect Field in Studio. In the field create a dependency. Then you can control which options are available based upon the dependency.