Skip to content

Instantly share code, notes, and snippets.

@blak3r
Last active December 14, 2015 05:29
Show Gist options
  • Save blak3r/5035577 to your computer and use it in GitHub Desktop.
Save blak3r/5035577 to your computer and use it in GitHub Desktop.
Example of how to use SugarLogic to SetPanelVisibility (ie toggle a panel on and off) http://developers.sugarcrm.com/wordpress/2011/06/13/learning-sugar-logic-using-custom-dependencies/
<?php
$dependencies['Cases']['panel_visibility'] = array(
'hooks' => array("edit"),
'trigger' => 'equal($status, "Closed")', //Optional, the trigger for the dependency. Defaults to 'true'.
'triggerFields' => array('status'),
'onload' => true,
//Actions is a list of actions to fire when the trigger is true
'actions' => array(
array(
'name' => 'SetPanelVisibility',
'params' => array(
'target' => 'detailpanel_2', // <-- get this by doing inspect element on the page, they're sequential though so can probably guess it.
'value' => 'true',
),
)
),
'notActions' => array(
array(
'name' => 'SetPanelVisibility',
'params' => array(
'target' => 'detailpanel_2',
'value' => 'false',
),
),
),
);
@blak3r
Copy link
Author

blak3r commented Feb 26, 2013

This could also be done with just an actions by putting the equal($status, "Closed") in the 'value' for the actions array.

@dmulvi
Copy link

dmulvi commented May 31, 2013

Just a note that if you want the visibility to work on detail view then you add an item to the hooks array titled "view". I had thought it was detail, but was wrong. Thanks for the gist blake!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment