Skip to content

Commit

Permalink
WIP: render currency in output.
Browse files Browse the repository at this point in the history
  • Loading branch information
torotil committed Dec 10, 2020
1 parent 2c35774 commit 6002b28
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions campaignion_donation_amount/components/donation_amount.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,19 @@ function _webform_render_donation_amount($component, $value = NULL, $filter = TR
$component['extra']['unique'] = FALSE;
$element = webform_component_invoke('number', 'render', $component, $value, $filter, $submission);
$element['#attributes']['class'][] = 'donation-amount';
$element['#attributes']['class'][] = 'donation-amount-' . $component['extra']['currency'];
$element['#attributes']['data-currency'] = $component['extra']['currency'];
if ($component['extra']['options']) {
$currency = currency_load($component['extra']['currency']);
$element['#type'] = 'select_or_other';
$element['#select_type'] = 'radios';
$element['#options'] = drupal_map_assoc($component['extra']['options']);
$element['#options'] = drupal_map_assoc($component['extra']['options'], function ($amount) use ($currency) {
return $currency->sign . ' ' . $amount;
});
$element['#other'] = !empty($component['extra']['other_text']) ? check_plain($component['extra']['other_text']) : t('Other...');
$element['#translatable'][] = 'other';
$element['#other_title'] = $element['#title'] . ' ' . $element['#other'];
$element['#other_title_display'] = 'invisible';
$element['#other_title'] = $currency->sign;
$element['#other_title_display'] = 'before';
$element['#other_unknown_defaults'] = 'other';
$element['#other_delimiter'] = ', ';
// Merge in Webform's #process function for Select or other.
Expand Down

0 comments on commit 6002b28

Please sign in to comment.