TRUE
);
$this->add('textarea', 'body_text', ts('Body - TEXT Format'),
- CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Component', 'body_text'),
- TRUE
+ CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Component', 'body_text')
);
$this->add('textarea', 'body_html', ts('Body - HTML Format'),
CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Component', 'body_html')
$this->addYesNo('is_default', ts('Default?'));
$this->addYesNo('is_active', ts('Enabled?'));
+ $this->addFormRule(array('CRM_Mailing_Form_Component', 'formRule'));
$this->addFormRule(array('CRM_Mailing_Form_Component', 'dataRule'));
$this->addButtons(array(
)) . '<ul>' . implode('', $dataErrors) . '</ul><br /><a href="' . CRM_Utils_System::docURL2('Tokens', TRUE, NULL, NULL, NULL, "wiki") . '">' . ts('More information on tokens...') . '</a>';
}
}
+ return empty($errors) ? TRUE : $errors;
+ }
+ /**
+ * Validates that either body text or body html is required.
+ * @param array $params
+ * (ref.) an assoc array of name/value pairs.
+ *
+ * @param $files
+ * @param $options
+ *
+ * @return bool|array
+ * mixed true or array of errors
+ */
+ public static function formRule($params, $files, $options) {
+ $errors = array();
+ if (empty($params['body_text']) && empty($params['body_html'])) {
+ $errors['body_text'] = ts("Please provide either HTML or TEXT format for the Body.");
+ $errors['body_html'] = ts("Please provide either HTML or TEXT format for the Body.");
+ }
return empty($errors) ? TRUE : $errors;
}