You are here

function _library_item_form in Library 6

Same name and namespace in other branches
  1. 5.2 library.module \_library_item_form()
  2. 6.2 library.module \_library_item_form()
  3. 7 library.module \_library_item_form()
2 calls to _library_item_form()
library_form_alter in ./library.module
Implementation of hook_form_alter()
library_item_js in ./library.module
Menu callback for AHAH additions.

File

./library.module, line 380

Code

function _library_item_form($delta, $item = array()) {
  $form = array(
    '#tree' => TRUE,
  );
  $form['id'] = array(
    '#type' => 'hidden',
    '#value' => isset($item['id']) ? $item['id'] : '',
    '#parents' => array(
      'items',
      $delta,
      'id',
    ),
  );
  if (variable_get('library_item_barcodes', LIBRARY_NO_BARCODES) == LIBRARY_BARCODES) {
    $form['barcode'] = array(
      '#type' => 'textfield',
      '#title' => t('Barcode'),
      '#default_value' => isset($item['barcode']) ? $item['barcode'] : '',
      '#required' => TRUE,
      '#parents' => array(
        'items',
        $delta,
        'barcode',
      ),
    );
  }
  $form['in_circulation'] = array(
    '#type' => 'checkbox',
    '#title' => t('Reference Only'),
    '#default_value' => isset($item['in_circulation']) ? $item['in_circulation'] : LIBRARY_CIRCULATION,
    '#return_value' => LIBRARY_REFERENCE_ONLY,
    '#parents' => array(
      'items',
      $delta,
      'in_circulation',
    ),
  );
  $form['notes'] = array(
    '#type' => 'textfield',
    '#title' => t('Notes'),
    '#size' => 20,
    '#maxlength' => 128,
    '#default_value' => isset($item['notes']) ? $item['notes'] : '',
    '#parents' => array(
      'items',
      $delta,
      'notes',
    ),
  );
  if ($delta > 0) {
    $form['delete'] = array(
      '#type' => 'checkbox',
      '#title' => t('Delete'),
      '#default_value' => 0,
      '#return_value' => 1,
      '#parents' => array(
        'items',
        $delta,
        'delete',
      ),
    );
  }
  if ($item['library_status'] == LIBRARY_ITEM_UNAVAILABLE) {
    $form['in_circulation']['#disabled'] = TRUE;
  }
  return $form;
}