public function GridFormController::validate in Grid builder 8
Overrides Drupal\Core\Entity\EntityFormController::validate().
File
- lib/
Drupal/ gridbuilder/ GridFormController.php, line 116 - Definition of Drupal\gridbuilder\GridFormController.
Class
- GridFormController
- Form controller for the grid edit/add forms.
Namespace
Drupal\gridbuilderCode
public function validate(array $form, array &$form_state) {
// Force width to 100 if fluid width. That is in percentages.
if ($form_state['values']['type'] == GRIDBUILDER_FLUID) {
$form_state['values']['width'] = 100;
}
if (intval($form_state['values']['width']) != $form_state['values']['width'] || $form_state['values']['width'] == 0) {
// Width should be a positive integer.
form_set_error('columns', t('The width should be a positive number.'));
}
if (intval($form_state['values']['columns']) != $form_state['values']['columns'] || $form_state['values']['columns'] == 0) {
// Columns should be a positive integer.
form_set_error('columns', t('The number of columns should be a positive number.'));
}
if (!is_numeric($form_state['values']['padding_width'])) {
// Padding can be float as well (eg. 1.5 for 1.5% for fluid grids).
form_set_error('padding_width', t('The column padding should be a number. Enter 0 (zero) for no padding.' . $form_state['values']['padding_width']));
}
if (!is_numeric($form_state['values']['gutter_width'])) {
// Gutter can be float too (eg. 1.5 for 1.5% for fluid grids).
form_set_error('gutter_width', t('The gutter width should be a number. Enter 0 (zero) for no gutter.'));
}
}