Skip to content

Instantly share code, notes, and snippets.

@Kobedinho
Last active January 12, 2017 19:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Kobedinho/539323f4acf476fa49833ab21416d2f4 to your computer and use it in GitHub Desktop.
Save Kobedinho/539323f4acf476fa49833ab21416d2f4 to your computer and use it in GitHub Desktop.
read only fields with dependencies, put the following code in: /custom/Extension/modules/<module>/Ext/Dependencies/custom_readonly_fields_logic.php
<?php
// Documentation.- http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.7/Architecture/Sugar_Logic/Dependency_Actions/
$dependencies['Meetings']['readonly_fields'] = array(
'hooks' => array("edit"), // values : "edit", "view", "save" and "all"
'trigger' => 'equal($status,"Held")', //Optional, the trigger for the dependency. Defaults to 'true'.
'triggerFields' => array('status'), // The list of fields to watch for change events. When changed, the trigger expressions will be recalculated.
'onload' => true, // Whether or not to trigger the dependencies when the page is loaded.
//Actions is a list of actions to fire when the trigger is true
// You could list multiple fields here each in their own array under 'actions'
'actions' => array(
array(
'name' => 'ReadOnly', // actions: ReadOnly, SetOptions, SetPanelVisibility, SetRequired, SetValue, SetVisibility
//The parameters passed in will depend on the action type set in 'name'
'params' => array(
'target' => 'status',
'value' => 'true',
),
),
),
// The list of dependencies to execute when the trigger expression is false
'notActions' => array(
),
);
@Kobedinho
Copy link
Author

Actions:
ReadOnly.- Is used to determine if a field is editable or not based on a formula.
SetOptions.- Is used to set the options list of a dropdown field based on a formula.
SetPanelVisibility.- Is used to determine the visibility of a record view panel based on a formula.
SetRequiredThe.- Is used to determine if a field is required.
SetValue.- Is used to set the value of a field based on a formula.
SetVisibility.- Is used to determine the visibility logic of a field based on a formula.

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