From: Seamus Lee Date: Sat, 23 Nov 2019 20:49:12 +0000 (+1100) Subject: dev/financial#105 Add in additional class onto the radio button payment processor... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=15a05fc2440e7cd222f2b11c8e4cbe5cd6bc0a24;p=civicrm-core.git dev/financial#105 Add in additional class onto the radio button payment processor options to differenciate between the different options for themers --- diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 2e102f83ee..376df66b38 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -320,10 +320,18 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $this->add('text', 'total_amount', ts('Total Amount'), ['readonly' => TRUE], FALSE); } $pps = $this->getProcessors(); - + $optAttributes = []; + foreach ($pps as $ppKey => $ppval) { + if ($ppKey > 0) { + $optAttributes[$ppKey]['class'] = 'payment_processor_' . strtolower($this->_paymentProcessors[$ppKey]['payment_processor_type']); + } + else { + $optAttributes[$ppKey]['class'] = 'payment_processor_paylater'; + } + } if (count($pps) > 1) { $this->addRadio('payment_processor_id', ts('Payment Method'), $pps, - NULL, " " + NULL, " ", FALSE, $optAttributes ); } elseif (!empty($pps)) { diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 5eb5167b31..35df75d34f 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -1150,17 +1150,29 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * @param array $attributes * @param null $separator * @param bool $required + * @param array $optionAttributes - Option specific attributes * * @return HTML_QuickForm_group */ - public function &addRadio($name, $title, $values, $attributes = [], $separator = NULL, $required = FALSE) { + public function &addRadio($name, $title, $values, $attributes = [], $separator = NULL, $required = FALSE, $optionAttributes = []) { $options = []; $attributes = $attributes ? $attributes : []; $allowClear = !empty($attributes['allowClear']); unset($attributes['allowClear']); $attributes['id_suffix'] = $name; foreach ($values as $key => $var) { - $options[] = $this->createElement('radio', NULL, NULL, $var, $key, $attributes); + $optAttributes = $attributes; + if (!empty($optionAttributes[$key])) { + foreach ($optionAttributes[$key] as $optAttr => $optVal) { + if (!empty($optAttributes[$optAttr])) { + $optAttributes[$optAttr] .= ' ' . $optVal; + } + else { + $optAttributes[$optAttr] = $optVal; + } + } + } + $options[] = $this->createElement('radio', NULL, NULL, $var, $key, $optAttributes); } $group = $this->addGroup($options, $name, $title, $separator); diff --git a/CRM/Event/Form/Registration/Register.php b/CRM/Event/Form/Registration/Register.php index 131e08eb28..1b5e56031c 100644 --- a/CRM/Event/Form/Registration/Register.php +++ b/CRM/Event/Form/Registration/Register.php @@ -398,9 +398,18 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { } if ($this->_values['event']['is_monetary']) { + $optAttributes = []; + foreach ($pps as $ppKey => $ppval) { + if ($ppKey > 0) { + $optAttributes[$ppKey]['class'] = 'payment_processor_' . strtolower($this->_paymentProcessors[$ppKey]['payment_processor_type']); + } + else { + $optAttributes[$ppKey]['class'] = 'payment_processor_paylater'; + } + } if (count($pps) > 1) { $this->addRadio('payment_processor_id', ts('Payment Method'), $pps, - NULL, " " + NULL, " ", FALSE, $optAttributes ); } elseif (!empty($pps)) {