You are here

function gridbuilder_grid_edit_form_validate in Grid builder 7

Validation for grid item settings form.

See also

gridbuilder_grid_edit_form().

1 string reference to 'gridbuilder_grid_edit_form_validate'
gridbuilder.inc in plugins/export_ui/gridbuilder.inc

File

plugins/export_ui/gridbuilder.inc, line 102

Code

function gridbuilder_grid_edit_form_validate(&$form, $form_state) {

  // Force width to 100 if fluid width. That is in percentages.
  if ($form_state['values']['grid_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.'));
  }
}