function homebox_configure_form_validate in Homebox 7.2
Same name and namespace in other branches
- 6.3 homebox.admin.inc \homebox_configure_form_validate()
- 6 homebox.admin.inc \homebox_configure_form_validate()
- 6.2 homebox.admin.inc \homebox_configure_form_validate()
- 7.3 homebox.admin.inc \homebox_configure_form_validate()
Forms for administration settings
_state
Parameters
$form:
File
- ./
homebox.admin.inc, line 830 - Homebox admin file, takes care admin interface for homebox
Code
function homebox_configure_form_validate($form, &$form_state) {
// Make sure the column choice is between 1-9
$columns = (int) $form_state['values']['columns'];
if ($columns < 1 || $columns > 9) {
form_set_error('columns', t('You must enter a value between 1 and 9.'));
}
// Check colors for string length and format - not valid HTML colors!
for ($i = 0; $i < HOMEBOX_NUMBER_OF_COLOURS; $i++) {
if (strlen($form_state['values']['block_color_' . $i]) != 7) {
form_set_error('block_color_' . $i, t('Colors must begin with a # and follow by 6 characters.'));
}
if (substr_count($form_state['values']['block_color_' . $i], '#') != 1) {
form_set_error('block_color_' . $i, t('Colors must begin with a # and follow by 6 characters.'));
}
}
// Validate custom column widths, if any
$widths = 0;
for ($i = 1; $i <= 9; $i++) {
if ($form_state['values']['width_' . $i]) {
$widths++;
}
}
// Only act if widths were entered
if ($widths) {
if ($widths != $columns) {
form_set_error('widths', t('When setting custom widths, you must specify exactly the amount of columns that are available.'));
}
else {
$widths = 0;
// Make sure values are numeric, between 1 and 100
for ($i = 1; $i <= $columns; $i++) {
if (!is_numeric($form_state['values']['width_' . $i]) || $form_state['values']['width_' . $i] > 100 || $form_state['values']['width_' . $i] < 0) {
form_set_error('width_' . $i, t('Custom column width values must be numeric and in between 0 and 100.'));
}
$widths++;
}
// Check the amount of widths again to make sure that all
// values were consecutive
if ($widths != $columns) {
form_set_error('widths', t('Custom widths must be entered consecutively.'));
}
}
}
}