Skip to content

Instantly share code, notes, and snippets.

@elchele
Created January 31, 2018 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elchele/2fcc453f5a3cd8c9a56bdae558a29e84 to your computer and use it in GitHub Desktop.
Save elchele/2fcc453f5a3cd8c9a56bdae558a29e84 to your computer and use it in GitHub Desktop.
Custom dependency to set a field as required based on another field's value
<?php
/* This example sets the Status Description field to required
if the Status field is set to 'Dead' within Leads module.
File: ./custom/Extension/modules/Leads/Ext/Dependencies/set_required.ext.php */
$dependencies['Leads']['req_status_desc_dep'] = array(
'hooks' => array("edit"),
'trigger' => 'true',
'triggerFields' => array('status'),
'onload' => true,
'actions' => array(
array(
'name' => 'SetRequired',
'params' => array(
'target' => 'status_description',
'label' => 'LBL_STATUS_DESCRIPTION',
'value' => 'equal($status, "Dead")'
)
),
),
//Actions fire if the trigger is false. Optional.
'notActions' => array(),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment