function uc_varprice_feature_form_validate in UC Variable Price 6
2 string references to 'uc_varprice_feature_form_validate'
- uc_varprice_form_alter in ./uc_varprice.module
- Implementation of hook_form_alter().
- _uc_varprice_feature_form in ./uc_varprice.module
File
- ./uc_varprice.module, line 468
- Defines a product feature to turn any product into a variable priced product.
Code
function uc_varprice_feature_form_validate($form, &$form_state) {
$form_state['values']['sel_options_arr'] = array();
foreach (array_unique(explode("\n", $form_state['values']['sel_options'])) as $value) {
list($value, $display) = explode('|', $value);
$display = trim($display);
$value = trim($value);
list($value, $uniqueness) = explode(':', $value);
if ($value !== '') {
if (!is_numeric($value)) {
form_set_error('sel_options', t('The value %val does not appear to be a number. Please enter only one number per line, without currency symbols.', array(
'%val' => $value,
)));
}
else {
$value_key = $uniqueness ? sprintf('%.2f', $value) . ":{$uniqueness}" : sprintf('%.2f', $value);
$form_state['values']['sel_options_arr'][$value_key] = $display ? $display : uc_currency_format($value);
}
}
}
}