function beautytips_admin_validate in BeautyTips 6.2
Same name and namespace in other branches
- 7.2 beautytips.admin.inc \beautytips_admin_validate()
Validation for beautytips settings form
File
- ./
beautytips.admin.inc, line 134 - Beautytips settings form and submit action
Code
function beautytips_admin_validate($form, &$form_state) {
$values = $form_state['values'];
$integer_fields = array(
'bt-options-box-strokeWidth',
'bt-options-box-cornerRadius',
'bt-options-box-spikeGirth',
'bt-options-box-spikeLength',
'bt-options-box-shadowBlur',
);
$pixel_fields = array(
'bt-options-box-width',
'bt-options-box-padding',
'bt-options-css-fontSize',
);
$color_fields = array(
'bt-options-box-fill',
'bt-options-css-color',
'bt-options-box-shadowColor',
);
$sanitize_strings = array(
'bt-options-cssClass',
'bt-options-css-fontFamily',
'bt-options-css-fontWeight',
);
foreach ($integer_fields as $name) {
if ($values[$name]) {
if (!is_numeric($values[$name])) {
form_set_error($name, t('You need to enter a numeric value for <em>@name</em>', array(
'@name' => str_replace(array(
'bt-options-box-',
'bt-options-css-',
), '', $name),
)));
}
else {
$form_state['values'][$name] = round($values[$name]);
}
}
}
foreach ($pixel_fields as $name) {
if ($values[$name]) {
$value = str_replace(array(
'px',
' ',
), '', $values[$name]);
if (!is_numeric($value) || !$value && $value != 0) {
form_set_error($name, t('You need to enter a numeric value for <em>@name</em>, followed by <em>px</em>', array(
'@name' => str_replace(array(
'bt-options-box-',
'bt-options-css-',
), '', $name),
)));
}
else {
$form_state['values'][$name] = round($values[$name]) . 'px';
}
}
}
foreach ($color_fields as $name) {
if ($values[$name]) {
$form_state['values'][$name] = check_plain($values[$name]);
}
}
foreach ($sanitize_strings as $name) {
if ($values[$name]) {
$form_state['values'][$name] = check_plain($values[$name]);
}
}
}