You are here

function block_skinr_form_index_handler in Skinr 6

Same name and namespace in other branches
  1. 6.2 modules/block.skinr.inc \block_skinr_form_index_handler()

Skinr form index handler.

Parameters

$op: What kind of action is being performed. Possible values:

  • "form": the form elements for Skinr are being inserted in a form
  • "submit": the form has been submitted.

&$form:

  • For "form", passes in the $form parameter from hook_form_alter().
  • For "submit", passes in the $form parameter from hook_form_submit().

$form_state:

  • For "form", passes in the $form_state parameter from hook_form_alter().
  • For "submit", passes in the $form_state parameter from hook_form_submit().

Return value

The index where we can find our values in Skinrs data structure.

Related topics

1 string reference to 'block_skinr_form_index_handler'
block_skinr_data in modules/block.skinr.inc
Implementation of hook_skinr_data().

File

modules/block.skinr.inc, line 54
Provide skinr handling for block.module

Code

function block_skinr_form_index_handler($op, &$form, $form_state) {
  switch ($op) {
    case 'form':
      return $form['module']['#value'] . '-' . $form['delta']['#value'];
    case 'submit':
      $form_id = $form['form_id']['#value'];
      if ($form_id == 'block_add_block_form') {

        // This is a new block, so we need to fetch the delta from DB
        if ($delta = db_result(db_query("SELECT delta FROM {blocks} WHERE bid = '%s'", db_last_insert_id('boxes', 'bid')))) {
          return $form_state['values']['module'] . '-' . $delta;
        }
      }
      else {
        return $form_state['values']['module'] . '-' . $form_state['values']['delta'];
      }
  }
}