From 5260bb5c31eccd9571bcfa21fbfc504288a58c5f Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 15 Feb 2014 16:09:21 -0800 Subject: [PATCH] CRM-13929 Refactor grant form --- CRM/Grant/Form/Grant.php | 29 +++-------------------------- templates/CRM/Grant/Form/Grant.tpl | 7 +++++-- templates/CRM/Grant/Page/Tab.tpl | 3 ++- xml/schema/Grant/Grant.xml | 4 ++-- 4 files changed, 12 insertions(+), 31 deletions(-) diff --git a/CRM/Grant/Form/Grant.php b/CRM/Grant/Form/Grant.php index b6f331d315..7173bed1c7 100644 --- a/CRM/Grant/Form/Grant.php +++ b/CRM/Grant/Form/Grant.php @@ -250,33 +250,10 @@ class CRM_Grant_Form_Grant extends CRM_Core_Form { ); if ($this->_context == 'standalone') { - CRM_Contact_Form_NewContact::buildQuickForm($this); - $this->addFormRule(array('CRM_Grant_Form_Grant', 'formRule'), $this); + $this->addEntityRef('contact_id', ts('Applicant'), array('create' => TRUE), TRUE); } } - /** - * global form rule - * - * @param array $fields the input form values - * @param array $files the uploaded files if any - * @param array $options additional user data - * - * @return true if no errors, else array of errors - * @access public - * @static - */ - static function formRule($fields, $files, $self) { - $errors = array(); - - //check if contact is selected in standalone mode - if (isset($fields['contact_select_id'][1]) && !$fields['contact_select_id'][1]) { - $errors['contact[1]'] = ts('Please select a contact or create new contact'); - } - - return $errors; - } - /** * Function to process the form * @@ -302,8 +279,8 @@ class CRM_Grant_Form_Grant extends CRM_Core_Form { } // set the contact, when contact is selected - if (!empty($params['contact_select_id'])) { - $this->_contactID = $params['contact_select_id'][1]; + if ($this->_context == 'standalone') { + $this->_contactID = $params['contact_id']; } $params['contact_id'] = $this->_contactID; diff --git a/templates/CRM/Grant/Form/Grant.tpl b/templates/CRM/Grant/Form/Grant.tpl index e3b7c1a05a..0d741729b5 100644 --- a/templates/CRM/Grant/Form/Grant.tpl +++ b/templates/CRM/Grant/Form/Grant.tpl @@ -48,8 +48,11 @@
{include file="CRM/common/formButtons.tpl" location="top"}
{if $context eq 'standalone'} - {include file="CRM/Contact/Form/NewContact.tpl"} - {/if} + + + + + {/if} diff --git a/templates/CRM/Grant/Page/Tab.tpl b/templates/CRM/Grant/Page/Tab.tpl index 8d89aa0dde..e6138316e5 100644 --- a/templates/CRM/Grant/Page/Tab.tpl +++ b/templates/CRM/Grant/Page/Tab.tpl @@ -36,7 +36,8 @@

{ts 1=$displayName}This page lists all grants for %1 since inception.{/ts} {if $permission EQ 'edit'} - {ts 1=$newGrantURL}Click Add Grant to record a Grant for this contact.{/ts} + {capture assign=link}accesskey='N' href='{$newGrantURL}' class='action-item'{/capture} + {ts 1=$link}Click Add Grant to record a Grant for this contact.{/ts} {/if}

diff --git a/xml/schema/Grant/Grant.xml b/xml/schema/Grant/Grant.xml index d61bdd9990..dac3136cac 100644 --- a/xml/schema/Grant/Grant.xml +++ b/xml/schema/Grant/Grant.xml @@ -94,7 +94,7 @@ grant_type_id int unsigned - Grant Type Id + Grant Type grant_type @@ -196,7 +196,7 @@ status_id int unsigned - Grant Status Id + Grant Status grant_status_id true true -- 2.25.1
{$form.contact_id.label}{$form.contact_id.html}
{$form.status_id.label} {$form.status_id.html}