private function wf_crm_admin_component::moneyOptions in Webform CiviCRM Integration 7.5
Same name and namespace in other branches
- 7.4 includes/wf_crm_admin_component.inc \wf_crm_admin_component::moneyOptions()
options_element alterations for when a currency field (e.g. contribution amount, event fee) is rendered as a select
1 call to wf_crm_admin_component::moneyOptions()
- wf_crm_admin_component::alterForm in includes/
wf_crm_admin_component.inc - Alter back-end webform component edit forms. Called by hook_form_alter() whenever editing a webform component.
File
- includes/
wf_crm_admin_component.inc, line 358
Class
Code
private function moneyOptions() {
form_load_include($this->form_state, 'inc', 'webform_civicrm', 'includes/wf_crm_admin_component');
$this->form['#validate'][] = 'wf_crm_money_validate';
if ($this->component['type'] === 'grid') {
$this->form['options']['#title'] = t('Amounts (columns)');
$this->form['options']['#description'] = t('Options to select across the top. Usually these are quantities. Keys must be numeric');
$this->form['questions']['#title'] = t('Items (rows)');
$this->form['questions']['#description'] = t('Items down the side of the grid. Usually the keys represent item price, which will be multiplied with the amount column.') . '<br />' . t('Use non-numeric keys to use the price from the amount column as-is with no multiplication.');
}
elseif ($this->component['type'] === 'select') {
$this->form['items']['options']['option_settings']['options_source']['#access'] = FALSE;
$this->form['items']['#description'] = t('Enter item labels and prices. If you allow the user to select multiple items their amounts will be added together.');
}
foreach ([
'items',
'options',
'questions',
] as $field) {
if (!empty($this->form[$field]['options']['#key_type_toggle'])) {
$this->form[$field]['options']['#key_type_toggle'] = t('Show Prices');
$this->form[$field]['options']['#key_type_toggled'] = TRUE;
}
}
// CSS trick to add currency symbol to options element keys
$symbol = wf_crm_get_civi_setting('defaultCurrencySymbol', '$');
drupal_add_css('
.option-key-cell:before {
content:"' . $symbol . '";
}
.options-widget .form-text.option-key {
width: 50%;
margin-left: .3em;
}', 'inline');
}