You are here

function gridbuilder_grid_edit_form in Grid builder 7

Grid item settings form.

See also

gridbuilder_grid_edit_form_validate().

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

File

plugins/export_ui/gridbuilder.inc, line 38

Code

function gridbuilder_grid_edit_form(&$form, $form_state) {
  $grid = $form_state['item'];

  // Common form elements are already provided by ctools for admin_title
  // (human readable label) and name (machine name).
  if (empty($grid->width)) {

    // Set some defaults for the user if this is a new grid.
    $grid->grid_type = GRIDBUILDER_FLUID;
    $grid->width = 100;
    $grid->columns = 12;
    $grid->padding_width = 1.5;
    $grid->gutter_width = 2;
  }

  // Master grid configuration.
  $form['grid_type'] = array(
    '#type' => 'radios',
    '#title' => t('Type of grid'),
    '#options' => array(
      GRIDBUILDER_FLUID => t('Fluid'),
      GRIDBUILDER_FIXED => t('Fixed to specific width'),
    ),
    '#default_value' => $grid->grid_type,
  );
  $form['width'] = array(
    '#type' => 'textfield',
    '#title' => t('Grid width'),
    '#description' => t('Only meaningful if using a fixed grid. Enter a pixel size (eg. 960).'),
    '#default_value' => $grid->width,
    '#states' => array(
      'visible' => array(
        'input[name="grid_type"]' => array(
          'value' => GRIDBUILDER_FIXED,
        ),
      ),
    ),
    '#field_suffix' => $grid->grid_type == GRIDBUILDER_FIXED ? 'px' : '%',
  );

  // Grid detail configuration.
  $form['columns'] = array(
    '#type' => 'textfield',
    '#title' => t('Number of grid columns'),
    '#default_value' => $grid->columns,
  );
  $form['padding_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Column padding'),
    '#description' => t('Column padding in pixels (for fixed grids, eg. 10) or percentages (for fluid grids, eg. 1.5). Enter 0 for no padding.'),
    '#default_value' => $grid->padding_width,
    '#field_suffix' => $grid->grid_type == GRIDBUILDER_FIXED ? 'px' : '%',
  );
  $form['gutter_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Gutter width'),
    '#description' => t('Gutter width in pixels (for fixed grids, eg. 20) or percentages (for fluid grids, eg. 2). Enter 0 for no gutter.'),
    '#default_value' => $grid->gutter_width,
    '#field_suffix' => $grid->grid_type == GRIDBUILDER_FIXED ? 'px' : '%',
  );
  $form['#attached']['css'][] = drupal_get_path('module', 'gridbuilder') . '/gridbuilder-admin.css';
  $form['#attached']['js'][] = drupal_get_path('module', 'gridbuilder') . '/gridbuilder-admin.js';
}