addElement('select', 'status_id', ts('Grant Status'), array('' => '') + $grantStatus); $this->addElement('text', 'amount_granted', ts('Amount Granted')); $this->addRule('amount_granted', ts('Please enter a valid amount.'), 'money'); $this->addDate('decision_date', ts('Grant Decision'), FALSE, array('formatType' => 'custom')); $this->assign('elements', array('status_id', 'amount_granted', 'decision_date')); $this->assign('totalSelectedGrants', count($this->_grantIds)); $this->addDefaultButtons(ts('Update Grants'), 'done'); } /** * Process the form after the input has been submitted and validated * * @access public * * @return void */ public function postProcess() { $updatedGrants = 0; // get the submitted form values. $params = $this->controller->exportValues($this->_name); $qfKey = $params['qfKey']; foreach ($params as $key => $value) { if ($value == '' || $key == 'qfKey') { unset($params[$key]); } } if (!empty($params)) { foreach ($params as $key => $value) { $values[$key] = $value; } foreach ($this->_grantIds as $grantId) { $ids['grant_id'] = $grantId; CRM_Grant_BAO_Grant::add($values, $ids); $updatedGrants++; } } $status = ts('Updated Grant(s): %1 (Total Selected: %2)', array(1 => $updatedGrants, 2 => count($this->_grantIds))); CRM_Core_Session::setStatus($status, '', 'info'); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/grant/search', 'force=1&qfKey=' . $qfKey)); } }