From 765eaf0ce7104bf3e14ea05ae67cd8644cde5ea6 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Wed, 28 Sep 2016 17:38:50 +0530 Subject: [PATCH] CRM-19423 - Move required behavior of mail_format to formrule --- CRM/Contact/Form/Edit/CommunicationPreferences.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CRM/Contact/Form/Edit/CommunicationPreferences.php b/CRM/Contact/Form/Edit/CommunicationPreferences.php index 378cd563c6..2bb555f81b 100644 --- a/CRM/Contact/Form/Edit/CommunicationPreferences.php +++ b/CRM/Contact/Form/Edit/CommunicationPreferences.php @@ -84,7 +84,7 @@ class CRM_Contact_Form_Edit_CommunicationPreferences { //using for display purpose. $form->assign('commPreference', $commPreference); - $form->addField('preferred_mail_format', array('entity' => 'contact', 'label' => ts('Email Format')), TRUE); + $form->addField('preferred_mail_format', array('entity' => 'contact', 'label' => ts('Email Format'))); $form->addField('is_opt_out', array('entity' => 'contact', 'label' => ts('NO BULK EMAILS (User Opt Out)'))); @@ -138,6 +138,10 @@ class CRM_Contact_Form_Edit_CommunicationPreferences { ); } } + + if (array_key_exists('preferred_mail_format', $fields) && empty($fields['preferred_mail_format'])) { + $errors['preferred_mail_format'] = ts('Please select an email format preferred by this contact.'); + } return empty($errors) ? TRUE : $errors; } -- 2.25.1