3
votes

Im using a form with several fields. When the create form view is loaded,only a select field will be visible with other fields set to hidden. Once I change the options of the select field, specific fields regarding to the option will be visible and will be hidden. I did this using trigger event from form field options.

product_type:
    label: Choose type
    type: dropdown
    options:
        web: Web 
        mobile: Mobile 

title:
    label: Title
    type: text
    trigger:
        action: show
        field: product_type
        condition: value[web]

It works good but since some specific fields has to be visible for two or more select options, I could not able to apply this method. Say, for example I want the price field to appear for both the web and mobile. But I could not able to set the trigger condition with additional value. I have referred this from the documentation. https://octobercms.com/docs/ui/input-trigger . Yet its not working

price:
    label: Price
    type: text
    trigger:
        action: show
        field: product_type
        condition: value[web][mobile]

At present I have solved this problem by definig filterFields method in model. https://octobercms.com/docs/backend/forms#filter-form-fields. Also I know how to do this in js

But what I want to know is that why the trigger condition is not supporting multiple values. Or did I made any mistake. Or should I have to include something else ?

2

2 Answers

2
votes

For me works like this

price:

label: Price
type: text
trigger:
    action: show
    field: product_type
    condition: value[web] | value[mobile]
0
votes

Even this works value[web][mobile]

label: Price
type: text
trigger:
    action: show
    field: product_type
    condition: value[web][mobile]

but not with the current version of october-min.js because some part of the js has been deprecated. I have identified this by viewing the pagesource of the js file from the documentation https://octobercms.com/docs/ui/input-trigger. In this documentation it is mentioned that it is possible and it also works with the example which is provided over there. So replace the trigger condition function defined in the local js file with the trigger condition function defined in the documentation js file . In local, the js file is located in modules\backend\assets\js\october-min.js. When you view the page source you could find the iframe; view the pagesource of the iframe and get the js file. Or else you could get the trigger condition function from http://kopy.io/tyehc.

But remember this is only to tell that trigger condition for multiple values is possible, I still dont know why it is not working with the installed october-min.js, may be the October CMS team could be working on it and they might announce an official updation.