Jason, this should work for you, I usually do these in code not studio.
Say you are in <yourmodule> and want dropdownA to change the values in dropdownB
also dropdownB should display only if fieldC has a value of "C1".
in custom/Extension/modules/<yourmodule>/Ext/Vardefs/<choose_a_name>.php
The visibility_grid determines which category values are displayed for which values of the trigger dropdown
While the dependency determines when the dropdown is visible
To Show B1 and B2 when A1 is chosen
and B3 when A2 is chosen:
[PHP]
$dictionary['<yourmoduleSingular>']['fields']['dropdownB']['visibility_grid'] = array (
'trigger' => 'dropdownA',
'values' => array (
'A1'=>array(
'' //the empty option if you want it
,'B1'
,'B2'
),
'A2'=>array(
''
,'B3'
),
),
);
[PHP]
To hide dropdownB unless fieldC == C1
in that same vardef extension file:
[PHP]
$dictionary['<yourmoduleSingular>']['fields']['dropdownB']['dependency'] = 'equal($fieldC,"C1")';
[PHP]
Additionally you can make the dropdown mandatory, say you want dropdownB to be mandatory when dropdwnA value is A1:
custom/Extension/modules/<yourmodule>/Ext/Dependencies
PHP Code:
<?php
$dependencies['<yourmodule>']['dropdownB'] = array(
'hooks' => array("edit"),
'trigger' => 'true',
'triggerFields' => array('dropdownA'),
'onload' => true,
//Actions is a list of actions to fire when the trigger is true
'actions' => array(
array(
'name' => 'SetRequired',
//The parameters passed in will depend on the action type set in 'name'
'params' => array(
'target' => 'dropdownB',
'label' => 'dropdownB_label',
'value' => 'equal($dropdownA, "A1")',
),
),
),
);
make sure the values are always the database values (not what the user sees in the front end).
Also note that the module name is singular (e.g. Contact) for the vardefs, but plural (e.g. Contacts) for the dependencies.
HTH
Francesca
Bookmarks