Hi,
I have created a form in this fashion that there are rows as many as records in the the database.
****************"****Start of Form"***********************************************
****************"****Starting of Loop"*********************************************
"Checkbox(column1)"............................ "Image(column2)".........................."Title(column3)"
..........
.........
........
.........
........
******************end of loop***************************************************
******************submit button*************************************************
******************end of form***************************************************
The checkboxes have the IDs of the records.
return drupal_get_form('acidfree_album_print_service', $form);
*************************************************************************
function acidfree_album_print_service()
{
global $user;
$type = new stdClass();
$type->message = t('There is no image');
$form = array();
$print_res = db_query("SELECT * FROM {print_service} where uid='$user->uid'");
$total_print_num = db_num_rows($print_res);
if($total_print_num>0)
{
while ($node = db_fetch_object($print_res))
{
$node = node_load($node->nid);
$confirm_nid = db_query("SELECT * FROM {node} where nid='$node->nid'");
$confirm_total_print_num = db_num_rows($confirm_nid);
if($confirm_total_print_num>0)
{
//$node->images[$file->filename] = $file->filepath;
$nodes[$node->nid] = '';
$form['album_print'][$node->nid] = array('#type' => 'checkbox');
$form['album_image'][$node->nid] = array('#type' => 'markup', '#value' => l(image_display($node, 'thumbnail'), 'node/'.$node->nid, array(), NULL, NULL, FALSE, TRUE));
$form['album_name'][$node->nid] = array(
'#type' => 'markup',
'#value' => t($node->title),
'#prefix' => '<div class="description">',
'#suffix' => '</div>',
);
} // end of if form confirm nodein
} // end of while loop
$form['album_print']['#tree'] = TRUE;
$form['album_image']['#tree'] = TRUE;
$form['album_name']['#tree'] = TRUE;
$form['album_results'] = array(
'#type' => 'item',
//'#title' => t('You have not uploaded any image for printing service'),
'#value' => t(''),
);
$form['submit'] = array(
'#type' => 'submit',
'#prefix' => '<div align="left">',
'#suffix' => '</div>',
'#value' => t('Print Now'),
);
//$form['#theme'] = 'sample_form_acidfree';
$form['#theme'] = 'acidfree_album_print_service';
} // end of if for $total_print_num
else
{
$form['album_results'] = array(
'#type' => 'item',
//'#title' => t('You have not uploaded any image for printing service'),
'#value' => t('You have not uploaded any image for printing service.'),
'#prefix' => '<div class="description">',
'#suffix' => '</div>',
);
//$form['#theme'] = 'sample_form_acidfree';
$form['#theme'] = 'acidfree_album_print_service';
//$form= drupal_render($form);
//print $form;
}
return $form;
}
************************************
function theme_acidfree_album_print_service($form){
$header = array('Select', 'Image', 'Name');
//$output .= drupal_render();
$rows = array();
foreach (element_children($form['album_print']) as $key) {
$rows[] = array(
drupal_render($form['album_print'][$key]),
drupal_render($form['album_image'][$key]),
drupal_render($form['album_name'][$key]),
// Add elements as needed, status, access, etc
);
}
if ( count($rows) ) {
$output .= theme('table', $header, $rows);
}
$output .= drupal_render($form);
return $output;
}
If there are 3 records, how will I get the ID of the records after submisstion.
I have spent alot of time to get its solution but could not get, now i am posting here.
Waiting for your help.
Crinch.
Comments
Have you read all the forms
Have you read all the forms API doc? I find it very helpful. Check the links at the bottom of this page. http://api.drupal.org/api/5
BTW drupal_get_form should only have one argument - form_id.
The form values should be available in $form_values in your form_id_submit() handler.
I'm pretty new to the form API myself but if you can get it on your side it's great!
The Drupal Pro Development book is also a must if you are doing serious development. has a chapter on form API. www.drupalbook.com
Good luck,
gpk
gpk
----
www.alexoria.co.uk