You are here

function library_node_form_submit in Library 6

Same name and namespace in other branches
  1. 5.2 library.module \library_node_form_submit()
  2. 6.2 library.module \library_node_form_submit()
  3. 7 library.module \library_node_form_submit()
1 string reference to 'library_node_form_submit'
library_form_alter in ./library.module
Implementation of hook_form_alter()

File

./library.module, line 344

Code

function library_node_form_submit($form, &$form_state) {
  if (variable_get('library_item_barcodes', LIBRARY_NO_BARCODES) == LIBRARY_BARCODES) {
    $node = node_submit($form_state['values']);
    $items = $node->items;
    $row = 0;
    $last_key = count($items) - 1;
    foreach ($items as $key => $item) {

      //Remove empty item instance if it's not being used
      if ($key > 0 && $key == $last_key && empty($item['id']) && empty($item['barcode'])) {
        unset($node->items[$key]);
      }
      $row++;
    }
    $form_state['values'] = (array) $node;
  }
}