1 queue_example.module queue_example_add_remove_form_insert($form, &$form_state)

Submit function for the insert-into-queue button.

Related topics


modules/examples/queue_example/queue_example.module, line 155
Examples demonstrating the Backdrop Queue API.


function queue_example_add_remove_form_insert($form, &$form_state) {
  // Get a queue (of the default type) called 'queue_example_queue'.
  // If the default queue class is SystemQueue this creates a queue that stores
  // its items in the database.
  $queue = BackdropQueue::get($form_state['values']['queue_name']);
  // There is no harm in trying to recreate existing.

  // Queue the string.
  $count = $queue->numberOfItems();
  backdrop_set_message(t('Queued your string (@string_to_add). There are now @count items in the queue.', array('@count' => $count, '@string_to_add' => $form_state['values']['string_to_add'])));
  // Setting 'rebuild' to TRUE allows us to keep information in $form_state.
  $form_state['rebuild'] = TRUE;
  // Unsetting the string_to_add allows us to set the incremented default value
  // for the user so they don't have to type anything.