function panels_flexible_settings_validate in Panels 5.2
Same name and namespace in other branches
- 6.2 layouts/flexible/flexible.inc \panels_flexible_settings_validate()
File
- layouts/
flexible.inc, line 204
Code
function panels_flexible_settings_validate($values, $form, $display, $layout, $settings) {
if ($values['rows'] < 1) {
form_error($form['rows'], t('Rows must be a positive integer.'));
return;
}
// Validate that percentages add up to the stated maximum.
if ($settings['width_type'] == '%') {
for ($row = 1; $row <= intval($values['rows']); $row++) {
// This takes into account whether or even had a previous setting here.
if ($settings['rows'] >= $row) {
if ($values["row_{$row}"]['columns'] < 1) {
form_error($form["row_{$row}"]['columns'], t('Columns must be a positive integer.'));
return;
}
$total = 0;
for ($col = 1; $col <= intval($values["row_{$row}"]["columns"]); $col++) {
$total += $values["row_{$row}"]["width_{$col}"];
}
if ($total != $settings['percent_width']) {
form_error($form["row_{$row}"]['columns'], t('Column widths must add up to 100.'));
}
}
}
}
}