From b9aa8f56b32b4fd6c587e805bb2565867ad140d5 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 15 Feb 2014 16:18:19 -0800 Subject: [PATCH] CRM-13929 Refactor pledge form --- CRM/Core/Form.php | 2 +- CRM/Pledge/Form/Pledge.php | 14 ++++---------- templates/CRM/Pledge/Form/Pledge.tpl | 11 +++++++---- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 654a46d2a1..0899588c65 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -1249,7 +1249,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * - entity - defaults to contact * - create - can the user create a new entity on-the-fly? * Set to TRUE if entity is contact and you want the default profiles, - * or pass in your own set of links. See output of CRM_Core_BAO_UFGroup::getCreateLinks for format + * or pass in your own set of links. @see CRM_Core_BAO_UFGroup::getCreateLinks for format * - api - array of settings for the getlist api * - placeholder - string * - multiple - bool diff --git a/CRM/Pledge/Form/Pledge.php b/CRM/Pledge/Form/Pledge.php index eeffdabcae..cb3a178713 100644 --- a/CRM/Pledge/Form/Pledge.php +++ b/CRM/Pledge/Form/Pledge.php @@ -276,7 +276,7 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { } if ($this->_context == 'standalone') { - CRM_Contact_Form_NewContact::buildQuickForm($this); + $this->addEntityRef('contact_id', ts('Contact'), array('create' => TRUE), TRUE); } $showAdditionalInfo = FALSE; @@ -492,11 +492,6 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { 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'); - } - if ($fields['amount'] <= 0) { $errors['amount'] = ts('Total Pledge Amount should be greater than zero.'); } @@ -534,11 +529,10 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { $formValues = $this->controller->exportValues($this->_name); // set the contact, when contact is selected - if (!empty($formValues['contact_select_id'])) { - $this->_contactID = $formValues['contact_select_id'][1]; + if (!empty($formValues['contact_id'])) { + $this->_contactID = $formValues['contact_id']; } - $config = CRM_Core_Config::singleton(); $session = CRM_Core_Session::singleton(); //get All Payments status types. @@ -549,7 +543,7 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { 'frequency_interval', 'frequency_day', 'installments', - 'financial_type_id', + 'financial_type_id', 'initial_reminder_day', 'max_reminders', 'additional_reminder_day', diff --git a/templates/CRM/Pledge/Form/Pledge.tpl b/templates/CRM/Pledge/Form/Pledge.tpl index 5812246f55..c9fce0eee9 100644 --- a/templates/CRM/Pledge/Form/Pledge.tpl +++ b/templates/CRM/Pledge/Form/Pledge.tpl @@ -59,10 +59,13 @@ {else} {if $context eq 'standalone'} - {if !$email and $outBound_option != 2} - {assign var='profileCreateCallback' value=1 } - {/if} - {include file="CRM/Contact/Form/NewContact.tpl"} + {if !$email and $outBound_option != 2} + {assign var='profileCreateCallback' value=1 } + {/if} + + + + {else} -- 2.25.1
{$form.contact_id.label}{$form.contact_id.html}
{ts}Pledge by{/ts}