Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/financial#105 Add CSS class onto the radio button payment processor options #15940

Merged
merged 1 commit into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions CRM/Contribute/Form/Contribution/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,18 @@ public function buildQuickForm() {
$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)) {
Expand Down
16 changes: 14 additions & 2 deletions CRM/Core/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -1150,17 +1150,29 @@ public function get_template_vars($name = NULL) {
* @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);

Expand Down
11 changes: 10 additions & 1 deletion CRM/Event/Form/Registration/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,18 @@ public function buildQuickForm() {
}

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)) {
Expand Down