Push value into array using form I am working on developing a type of bucket that would store my selected content in some sort of data container (I am hoping to store it in an array). The selected data comes from default views, I wrote an handler to add a 'ADD' button to the default view. 
I am new to drupal and have very less experience with form api and not really sure how to push/store the selected content. 

The following is the handler code: 

&lt;?php

 /**
 * @file
 * handler class for the new field 'bucket'
 */

/**
* class definition
*/
  class bucket_views_handler_field_actions extends views_handler_field {
 /**
 * Render function: return html output
 */
  function render($values) {
   //debug ($values);
    $biomaterial_id=$values-&gt;biomaterial_id;
    $form=array();
    $form['Add']=array(
     '#type'=&gt;'button',
     '#value'=&gt;'ADD',
     '#access'=&gt;TRUE,
      );
  }
You could try creating a session variable. Taken from this question

You can try this.

function lists_session($key, $value = NULL) {
static $storage;
if ($value) {
$storage[$key] = $value ;
$_SESSION['lists'][$key] = $value ;   // I use 'lists' in case some other module uses 'type' in $_SESSION
}
else if (empty($storage[$key]) &amp;&amp; isset($_SESSION['lists'][$key])) {
$storage[$key] = $_SESSION['lists'][$key];
}
return $storage[$key];
}


So, to save a variable in Session:

lists_session("s_key", "value");


And to retrieve the value, just use:

$myVar = lists_session("s_key");


EDIT

To attach the above to the form submit (Add), try the following, taken from this question. You can do this in template.php with THEMENAME_form_alter if you prefer not to create a new module, but it would be theme specific if you do that.

You will need to create a custom module with hook_form_alter() implementation.

function [YOUR_MODULE]_form_alter(&amp;$form, &amp;$form_state, $form_id)
{
  if($form_id == "YOUR_FORM_ID")
  {
    // target the submit button and add a new submission callback routine to the form
    $form['#submit'][] = 'YOUR_SUBMISSION_CALLBACK_FUNCTION';
  }
}


The code above will execute your new callback function YOUR_SUBMISSION_CALLBACK_FUNCTION AFTER the form's default callback function.

To make your new callback function called BEFORE the form's default callback function, use the following code instead of the giving above:

array_unshift($form['#submit'], 'YOUR_SUBMISSION_CALLBACK_FUNCTION');


To cancel the form's default callback function and force it to use your function ONLY, use the code below

$form['#submit'] = array('YOUR_SUBMISSION_CALLBACK_FUNCTION');