Closed (works as designed)
Project:
Form Save
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
4 Jul 2012 at 11:41 UTC
Updated:
21 Jul 2012 at 23:33 UTC
i have loaded the records from table into forms and used theme to show it as a table but when i am accessing these records in form_submit function , it is showing only last record what should i do to get all values from form into tht submit funtion ? when i use dpm fuction in submit function it only shows last value.
function flower_order_form($form_state,$bqid1=0) {
$placeholders = implode(', ', array_fill(0, count($bqid1), "%d"));
$sql = "SELECT distinct flower_order.bqid, flowers.flowertype,flower_order.nof FROM {flower_order, flowers, cust_info} WHERE flower_order.bqid = $placeholders and flower_order.fid = flowers.fid" ;
$rs = db_query($sql,$bqid1);
if ($rs) {
$counter=1;
while ($data = db_fetch_object($rs)) {
$form[$counter]['flowertype'] = array(
'#title' => t('flower type'),
'#size' => 60,
'#maxlength' => 64,
'#required' => TRUE,
'#value' => $data->flowertype
);
$form[$counter]['nof'] = array(
'#type' => 'textfield',
'#title' => t('nof'),
'#size' => 60,
'#maxlength' => 64,
'#required' => TRUE,
'#value' => $data->nof
);
$counter = $counter + 1 ;
}
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
$form['#theme'] = 'flower_order_form';
//dpm($form);
return $form;
};
function registration_theme() {
$theme['flower_order_form'] = array(
'arguments' => array('form' => array()),
);
return $theme;
}
function theme_flower_order_form($form) {
//dpm($form);
$rows = array();
foreach (element_children($form) as $counter) {
$row = array();
$row[] = array('data' => drupal_render($form[$counter]['flowertype']));
$row[] = array('data' => drupal_render($form[$counter]['nof']));
$rows[] = $row;
}
// Individual table headers.
$header = array();
//$header[] = t('bqid');
$header[] = t('flowertype');
$header[] = array('data' => t('nof'), 'class' => 'textfield');
$output = theme('table', $header, $rows);
$output .= drupal_render($form);
return $output;
}
function flower_order_form_submit($form_id, $form_state) {
// what to write here to get all the value from form so that i can perform my further query. Becoz if i am using dpm ($form_state) it is only displaying last value of tht particular table.
}
| Comment | File | Size | Author |
|---|---|---|---|
| function flower.pdf | 99.28 KB | ranjeetsingh89 |
Comments
Comment #1
ranjeetsingh89 commentedi am working Drupal 6 and need how to use loop to access all the value or i have to change my flower_order form logic.
Comment #2
timhilliard commentedHi ranjeetsingh89,
This looks to be an issue that you are having that is not related to the Form Save project but rather a general drupal problem you need support with. Please head over to http://drupal.org/support and try the documentation or forums for help solving your problem.
Cheers,
Tim
Comment #2.0
timhilliard commentedmy code is like this