You are here

function boxes_box_form in Boxes 6

Same name and namespace in other branches
  1. 7 boxes.module \boxes_box_form()

Common element of the box form

2 calls to boxes_box_form()
boxes_add_form in ./boxes.admin.inc
Generate form for creating new boxes.
boxes_block in ./boxes.module
Implementation of hook_block().
2 string references to 'boxes_box_form'
boxes_block in ./boxes.module
Implementation of hook_block().
boxes_footer in ./boxes.module
Implementation of hook_footer().

File

./boxes.module, line 266

Code

function boxes_box_form($form_state) {
  $box = $form_state['box'];
  $form = array();

  // For hook_block('save').
  if (method_exists($box, "box_form")) {
    $form = $box
      ->box_form($form_state);
    return $form;
  }
  $form['plugin_key'] = array(
    '#type' => 'value',
    '#value' => $box->plugin_key,
  );
  $form['delta'] = array(
    '#type' => 'value',
    '#value' => $box->delta,
  );
  $form['description'] = array(
    '#type' => 'textfield',
    '#title' => t('Box description'),
    '#default_value' => $box->description,
    '#maxlength' => 64,
    '#description' => t('A brief description of your box. Used for administrative purposes.'),
    '#required' => TRUE,
    '#weight' => -19,
  );
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Box title'),
    '#maxlength' => 64,
    '#description' => t('The rendered title of the box as shown to the user.'),
    '#default_value' => $box->title,
    '#weight' => -18,
  );
  $form['options'] = $box
    ->options_form();
  $form['options']['#weight'] = -17;
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#attributes' => array(
      'class' => 'boxes-ajax',
    ),
  );
  if (!empty($form_state['custom_action'])) {
    $form['#action'] = url($_GET['q'], array(
      'query' => array(
        'boxes_delta' => $box->delta,
        'plugin_key' => $form_state['plugin_key'],
      ),
    ));
  }
  return $form;
}