array('entity' => 'contribution', 'label' => ts('Payment Method'), 'option_url' => NULL, 'placeholder' => ts('- any -'))
);
- $form->add('select', 'contribution_pcp_made_through_id',
- ts('Personal Campaign Page'),
- array(
- '' => ts('- any -'),
- ) +
- CRM_Contribute_PseudoConstant::pcPage(),
- FALSE, array('class' => 'crm-select2')
- );
-
- $status = array();
+ // Fixme: Not a true entityRef field. Relies on PCP.js.tpl
+ $form->add('text', 'contribution_pcp_made_through_id', ts('Personal Campaign Page'), array('class' => 'twenty', 'id' => 'pcp_made_through_id', 'placeholder' => ts('- any -')));
+ // stores the label
+ $form->add('hidden', 'pcp_made_through');
$statusValues = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status');
// Remove status values that are only used for recurring contributions or pledges (In Progress, Overdue).
$siteHasPCPs = CRM_Contribute_PseudoConstant::pcPage();
if (!CRM_Utils_Array::crmIsEmptyArray($siteHasPCPs)) {
$form->assign('siteHasPCPs', 1);
- $form->add('hidden', 'pcp_made_through'); // stores the label
- $form->add('text', 'pcp_made_through_id', ts('Credit to a Personal Campaign Page'), array('class' => 'twenty'));
+ // Fixme: Not a true entityRef field. Relies on PCP.js.tpl
+ $form->add('text', 'pcp_made_through_id', ts('Credit to a Personal Campaign Page'), array('class' => 'twenty', 'placeholder' => ts('- select -')));
+ // stores the label
+ $form->add('hidden', 'pcp_made_through');
$form->addElement('checkbox', 'pcp_display_in_roll', ts('Display in Honor Roll?'), NULL);
$form->addElement('text', 'pcp_roll_nickname', ts('Name (for Honor Roll)'));
$form->addElement('textarea', 'pcp_personal_note', ts('Personal Note (for Honor Roll)'));
<td class="label">{$form.pcp_made_through_id.label}</td>
<td>
{$form.pcp_made_through_id.html}
- <span class="description">{ts}Search for the Personal Campaign Page by the fund-raiser's last name or email address.{/ts}</span>
+ <div class="description">{ts}Search for the Personal Campaign Page by the fund-raiser's last name or email address.{/ts}</div>
<div class="spacer"></div>
<div class="crm-contribution-form-block-pcp_details">
<tr id="nickID" class="crm-contribution-form-block-pcp_roll_nickname">
<td class="label">{$form.pcp_roll_nickname.label}</td>
<td>{$form.pcp_roll_nickname.html|crmAddClass:big}<br/>
- <span class="description">{ts}Name or nickname contributor wants to be displayed in the Honor Roll. Enter "Anonymous" for anonymous contributions.{/ts}</span>
+ <div class="description">{ts}Name or nickname contributor wants to be displayed in the Honor Roll. Enter "Anonymous" for anonymous contributions.{/ts}</div>
</td>
</tr>
<tr id="personalNoteID" class="crm-contribution-form-block-pcp_personal_note">
<td class="label" style="vertical-align: top">{$form.pcp_personal_note.label}</td>
<td>
{$form.pcp_personal_note.html}
- <span
- class="description">{ts}Personal message submitted by contributor for display in the Honor Roll.{/ts}</span>
+ <div
+ class="description">{ts}Personal message submitted by contributor for display in the Honor Roll.{/ts}</div>
</td>
</tr>
</table>
</table>
</div>
</div>
+ {include file="CRM/Contribute/Form/PCP.js.tpl"}
{/if}
<!-- end of PCP -->
--- /dev/null
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.6 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+*}
+{literal}
+<script type="text/javascript">
+ CRM.$(function($) {
+ var $form = $("form.{/literal}{$form.formClass}{literal}");
+
+ // FIXME: This could be much simpler as an entityRef field but pcp doesn't have a searchable api :(
+ var pcpURL = CRM.url('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getPCPList&json=1&context=contact&reset=1');
+ $('#pcp_made_through_id').crmSelect2({
+ minimumInputLength: 1,
+ ajax: {
+ url: pcpURL,
+ data: function(term, page) {
+ return {term: term, page: page};
+ },
+ results: function(response) {
+ return response;
+ }
+ },
+ initSelection: function(el, callback) {
+ callback({id: $(el).val(), text: $('[name=pcp_made_through]', $form).val()});
+ }
+ })
+ // This is just a cheap trick to store the name when the form reloads
+ .on('change', function() {
+ $('[name=pcp_made_through]', $form).val($(this).select2('data').text || '');
+ });
+ });
+</script>
+{/literal}
<tr>
<td>
{$form.contribution_pcp_made_through_id.label} <br />
- {$form.contribution_pcp_made_through_id.html|crmAddClass:twenty}
+ {$form.contribution_pcp_made_through_id.html}
+ {include file="CRM/Contribute/Form/PCP.js.tpl"}
</td>
<td>
{$form.contribution_pcp_display_in_roll.label}
return false;
});
- // FIXME: This could be much simpler as an entityRef field but pcp doesn't have a searchable api :(
- var pcpURL = CRM.url('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getPCPList&json=1&context=contact&reset=1');
- $('#pcp_made_through_id').crmSelect2({
- placeholder: {/literal}'{ts escape="js"}- select -{/ts}'{literal},
- minimumInputLength: 1,
- ajax: {
- url: pcpURL,
- data: function(term, page) {
- return {term: term, page: page};
- },
- results: function(response) {
- return response;
- }
- },
- initSelection: function(el, callback) {
- callback({id: $(el).val(), text: $('[name=pcp_made_through]', $form).val()});
- }
- })
- // This is just a cheap trick to store the name in case of a formrule error
- .on('change', function() {
- $('[name=pcp_made_through]', $form).val($(this).select2('data').text || '');
- });
-
$('.crm-soft-credit-block tr span').each(function () {
if ($(this).hasClass('crm-error')) {
$(this).parents('tr').show();