From: Lars SG Date: Sat, 17 Apr 2021 15:22:09 +0000 (-0600) Subject: Put text inside label tags for recurring contribution selection X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4e0a5deb2ad99753ad480af8eeda4af5990df10b;p=civicrm-core.git Put text inside label tags for recurring contribution selection All text now inside label tags except for the "for" when offering instalments. This allows styling. --- diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index b6c29b41fc..64d7ee6df3 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -730,17 +730,6 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu ])); } - $form->add('checkbox', 'is_recur', ts('I want to contribute this amount'), NULL); - - if (!empty($form->_values['is_recur_interval']) || $className == 'CRM_Contribute_Form_Contribution') { - $form->add('text', 'frequency_interval', ts('Every'), $attributes['frequency_interval'] + ['aria-label' => ts('Every')]); - $form->addRule('frequency_interval', ts('Frequency must be a whole number (EXAMPLE: Every 3 months).'), 'integer'); - } - else { - // make sure frequency_interval is submitted as 1 if given no choice to user. - $form->add('hidden', 'frequency_interval', 1); - } - $frUnits = $form->_values['recur_frequency_unit'] ?? NULL; if (empty($frUnits) && $className == 'CRM_Contribute_Form_Contribution' @@ -752,6 +741,21 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $unitVals = explode(CRM_Core_DAO::VALUE_SEPARATOR, $frUnits); + + // FIXME: Ideally we should freeze select box if there is only + // one option but looks there is some problem /w QF freeze. + //if ( count( $units ) == 1 ) { + //$frequencyUnit->freeze( ); + //} + + $form->add('text', 'installments', ts('installments'), + $attributes['installments'] + ); + $form->addRule('installments', ts('Number of installments must be a whole number.'), 'integer'); + + $is_recur_label = ts('I want to contribute this amount every'); + $unit_label = ts('Every'); + // CRM 10860, display text instead of a dropdown if there's only 1 frequency unit if (count($unitVals) == 1) { $form->assign('one_frequency_unit', TRUE); @@ -759,8 +763,13 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $form->add('hidden', 'frequency_unit', $unit); if (!empty($form->_values['is_recur_interval']) || $className == 'CRM_Contribute_Form_Contribution') { $unit .= "(s)"; + $form->assign('frequency_unit', $unit); + } else { + $is_recur_label = ts('I want to contribute this amount every %1', + [1 => $unit] + ); + $form->assign('all_text_recur', TRUE); } - $form->assign('frequency_unit', $unit); } else { $form->assign('one_frequency_unit', FALSE); @@ -771,22 +780,23 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $units[$val] = $frequencyUnits[$val]; if (!empty($form->_values['is_recur_interval']) || $className == 'CRM_Contribute_Form_Contribution') { $units[$val] = "{$frequencyUnits[$val]}(s)"; + $unit = ts('Every'); } } } $frequencyUnit = &$form->addElement('select', 'frequency_unit', NULL, $units, ['aria-label' => ts('Frequency Unit')]); } - // FIXME: Ideally we should freeze select box if there is only - // one option but looks there is some problem /w QF freeze. - //if ( count( $units ) == 1 ) { - //$frequencyUnit->freeze( ); - //} + if (!empty($form->_values['is_recur_interval']) || $className == 'CRM_Contribute_Form_Contribution') { + $form->add('text', 'frequency_interval', $unit, $attributes['frequency_interval'] + ['aria-label' => ts('Every')]); + $form->addRule('frequency_interval', ts('Frequency must be a whole number (EXAMPLE: Every 3 months).'), 'integer'); + } + else { + // make sure frequency_interval is submitted as 1 if given no choice to user. + $form->add('hidden', 'frequency_interval', 1); + } - $form->add('text', 'installments', ts('installments'), - $attributes['installments'] - ); - $form->addRule('installments', ts('Number of installments must be a whole number.'), 'integer'); + $form->add('checkbox', 'is_recur', $is_recur_label, NULL); } /** diff --git a/templates/CRM/Contribute/Form/Contribution/Main.tpl b/templates/CRM/Contribute/Form/Contribution/Main.tpl index 1a8d218053..0157fd13a0 100644 --- a/templates/CRM/Contribute/Form/Contribution/Main.tpl +++ b/templates/CRM/Contribute/Form/Contribution/Main.tpl @@ -145,14 +145,16 @@
 
- {$form.is_recur.html} {$form.is_recur.label} {ts}every{/ts} + {$form.is_recur.html} {$form.is_recur.label} {if $is_recur_interval} {$form.frequency_interval.html} {/if} - {if $one_frequency_unit} - {$frequency_unit} - {else} - {$form.frequency_unit.html} + {if !$all_text_recur} + {if $one_frequency_unit} + {$form.frequency_interval.label} + {else} + {$form.frequency_unit.html} + {/if} {/if} {if $is_recur_installments}