AnsweredAssumed Answered

How can you use SugarLogic to make the email address field required?

Question asked by Jeff Bickart on Mar 31, 2016
Latest reply on Apr 1, 2016 by Francesca Shiekh

I am working on the Contacts module. I want to ensure that the user of the application has entered either a Mobile Phone Number or an Email Address or both?


I would like to do this as a Dependency in custom/Extension/modules/Contacts/Ext/Dependencies


Here is my code that says that you need to enter at least 1 phone number. But the logic should say at least 1 phone number or an email address.


Any ideas? I have tried to add equal($email, ""), equal(count($email), 0) but I can't seem to get it to work.


$dependencies['Contacts']['phone_required'] = array(
   'hooks' => array("edit"),
   'trigger' => 'true', //Optional, the trigger for the dependency. Defaults to 'true'.
   'triggerFields' => array('phone_mobile', 'phone_other', 'phone_work', 'phone_home', 'emails'),
   'onload' => true,
   //Actions is a list of actions to fire when the trigger is true
   'actions' => array(
   'name' => 'SetRequired',
   //The parameters passed in will depend on the action type set in 'name'
   'params' => array(
   'target' => 'phone_home',
   'label'  => 'phone_home_label',
   'value' => 'and(equal($phone_mobile, ""),equal($phone_other, ""),equal($phone_work, ""))',