AnsweredAssumed Answered

Sugarlogic or syntax

Question asked by Mike Solomon on Jul 14, 2014
Latest reply on Jul 16, 2014 by Chris Hall
I'm using SugarLogic to hide a field dependening on status

I;ve got it working but was wondering if there was a better way of writing my code

At the moment 2 of my statuses have the same action but I can't work out thee syntax to use or so I have created 2 seperate statements

In the past I've not bothered with SugarLogic as I've found using Javascript was easier but now I'm upgrading to 7.2 it makes sense for me to use it

My code is:

//hide if status = open
$dependencies['zz_expenses_head']['date_start1'] = array(
        'hooks' => array("edit"),
        'trigger' => 'equal($status, "open")',//Optional, the trigger
        'triggerFields' => array('status'),
        'onload' => true,
        //Actions is a list of actions to fire when the trigger is true
        'actions' => array(
                array(
                        'name' => 'SetVisibility',
                        //The parameters passed in will depend on the action type set in 'name'
                        'params' => array(
                                'target' => 'date_paid',
                                'value' => 'false',
                        ),
                ),
        ),
);

//hide if status = submitted
$dependencies['zz_expenses_head']['date_start1a'] = array(
        'hooks' => array("edit"),
        'trigger' => 'equal($status, "submitted")',//Optional, the trigger
        'triggerFields' => array('status'),
        'onload' => true,
        //Actions is a list of actions to fire when the trigger is true
        'actions' => array(
                array(
                        'name' => 'SetVisibility',
                        //The parameters passed in will depend on the action type set in 'name'
                        'params' => array(
                                'target' => 'date_paid',
                                'value' => 'false',
                        ),
                ),
        ),
);

//show if status = authorised
$dependencies['zz_expenses_head']['date_start1b'] = array(
        'hooks' => array("edit"),
        'trigger' => 'equal($status, "authorised")',//Optional, the trigger
        'triggerFields' => array('status'),
        'onload' => true,
        //Actions is a list of actions to fire when the trigger is true
        'actions' => array(
                array(
                        'name' => 'SetVisibility',
                        //The parameters passed in will depend on the action type set in 'name'
                        'params' => array(
                                'target' => 'date_paid',
                                'value' => 'true',
                        ),
                ),
        ),
);

//readonly if status = finished
$dependencies['zz_expenses_head']['date_start2'] = array(
        'hooks' => array("edit"),
        'trigger' => 'equal($status, "finished")', //Optional, the trigger
        'triggerFields' => array('status'),
        'onload' => true,
        //Actions is a list of actions to fire when the trigger is true
        'actions' => array(
                array(
                        'name' => 'ReadOnly',
                        //The parameters passed in will depend on the action type set in 'name'
                        'params' => array(
                                'target' => 'date_paid',
                                'value' => 'true',
                        ),
                ),
        ),
);


Outcomes