Is their any way to generate a the same form giving it different information on the same page multiple times?
My end goal is to simply have multiple submit buttons on a single page, each one submitting something different.
This all needs to be dynamic, so I can not create a form for each button by hand.
This is what I have for the form set up
/*
* A form, just the add button. Ticker to add is bassed upon variable passed in.
* @return: HTML formatted tab.
*/
function stock_watchlist_add_button_form($ticker=NULL) {
if($ticker) {
$form['Ticker'] = array(
'#type' => 'hidden',
'#value' => $ticker
);
$form['user'] = array('#type' => 'value', '#value' => $GLOBALS['user']->uid);
// the submit buttom
$form['submit'] = array('#type' => 'submit', '#value' => t('Add'));
return $form;
}
}
/*
* Called when the button for stock_watchlist_add_button_form. Puts value into the DB and sets the status message.
* @param: $form_id
* @param: @form_values
*/
function stock_watchlist_add_button_form_submit($form_id, $form_values) {
db_query("INSERT INTO stock_watchlist (user_id, ticker, date_added, close_when_added, scan, date_range) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')" , $form_values['user'], $form_values['Ticker'], date("d/M/Y"), $close,'--','--');