Skip to content

Commit

Permalink
added formRule to prevent conflict between barcode and civicrm#4, CRM…
Browse files Browse the repository at this point in the history
…-12965
  • Loading branch information
kurund committed Jul 12, 2013
1 parent 0965112 commit 890a1fb
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions CRM/Badge/Form/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,34 @@ public function buildQuickForm() {
$this->add('checkbox', 'is_default', ts('Default?'));
$this->add('checkbox', 'is_active', ts('Enabled?'));
$this->add('checkbox', 'is_reserved', ts('Reserved?'));

$this->addFormRule(array('CRM_Badge_Form_Layout', 'formRule'));
}

/**
* form rule
*
* @param array $fields the input form values
*
* @return true if no errors, else array of errors
* @access public
* @static
*/
static function formRule($fields) {
$errors = array();

if (CRM_Utils_Array::value(4, $fields['token'])
&& CRM_Utils_Array::value('add_barcode', $fields)
&& (CRM_Utils_Array::value('barcode_alignment', $fields) == CRM_Utils_Array::value(4, $fields['text_alignment']))
) {
$errors['barcode_alignment'] = ts('You cannot have same alignment for barcode and #4 row.');
}

if (!empty($errors)) {
return $errors;
}

return empty($errors) ? TRUE : $errors;
}

/**
Expand Down

0 comments on commit 890a1fb

Please sign in to comment.