array( 'type' => 'numeric', 'title' => 'Federal Poverty Guidelines (FPG) %', 'group' => '', 'precision' => 0, 'negative' => false, 'prefix' => '%' ), 'monthlyPremium' => array( 'type' => 'numeric', 'title' => 'Monthly Premium Per Person $', 'group' => '', 'precision' => 2, 'decimal' => '.', 'negative' => false, 'prefix' => '$' ), '_options' => array( 'type' => 'options', 'title' => 'Options', ), ); $this->addElement('grid', 'premium', array( 'itemName' => 'row', 'required' => true, 'columns' => $columnsOptions, 'label' => 'MinnesotaCare Premium' ) ); $this->getElement('premium')->getDecorator('Label') ->setOption('escape', false) ->setOption( 'htmlAfterLabel', '

' . 'The percentages below show what the consumer needs to be under to qualify for that premium amount. For example, the highest premium amount applies to those under 201%, but above the next highest premium amount.' . '

' ); $this->addFormRule(array($this, 'validateForm')); return $this; } public function validateForm($data) { $errors = array(); $this->_validatePremium($data['premium'], $errors); return (!empty($errors) ? $errors : true); } protected function _validatePremium(array $data, &$errors) { $emptyError = ' is required and can\'t be empty'; foreach ($data as $key => $row) { $rowNum = $key + 1; if ($row['fpg'] == '' && $row['monthlyPremium'] == '') { $errors['premium'] = 'MinnesotaCare Premium data ' . $emptyError . ' at row #' . $rowNum; } elseif ($row['fpg'] != '' && $row['monthlyPremium'] == '') { $errors['premium'] = 'Monthly Premium value' . $emptyError . ' at row #' . $rowNum; } elseif ($row['monthlyPremium'] != '' && $row['fpg'] == '') { $errors['premium'] = 'FPG value' . $emptyError . ' at row #' . $rowNum; } if (!empty($errors)) { break; } } return $this; } }