I encourage you to start with a working example and build from there. There are several examples in the Form Example in Examples project (<a href="http://drupal.org/project/examples">http://drupal.org/project/examples</a>), and there are examples throughout core that you can look at. <br>
<br>In addition, focus on learning how to debug so you can solve these yourself. <a href="http://randyfay.com/debugging_drupal">http://randyfay.com/debugging_drupal</a> may be useful to you, and the Devel module with its dsm() function is widely used by people to figure out what's going on in situations like this.<br>
<br>This is a very helpful group, but they won't (usually) help you debug your code or learn the basics of Drupal development.<br><br>-Randy<br><br><div class="gmail_quote">On Sat, Jan 8, 2011 at 5:42 AM, mahesh gajabar <span dir="ltr"><<a href="mailto:mahesh143an@gmail.com">mahesh143an@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><span style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="color: rgb(34, 34, 34); font-family: 'Lucida Grande','DejaVu Sans','Bitstream Vera Sans',Verdana,Arial,sans-serif; font-size: 13px; line-height: 18px;"><p style="border-width: 0px; background-color: transparent; font-size: 13px; margin: 0px 0px 0.692em; padding: 0px; vertical-align: baseline;">
Hi <br></p><p style="border-width: 0px; background-color: transparent; font-size: 13px; margin: 0px 0px 0.692em; padding: 0px; vertical-align: baseline;">I have wrote custom module for showing values in html format table. I have delete and edit action for every row. My delete function working but edit function not working .Whats wrong with code. What i need to do corrections for it.For editing the form i NEED TO BE get default values in form that too not getting.please help me guys</p>
<blockquote style="border-width: 0px; background-color: rgb(255, 255, 255); font-size: 13px; margin: 1.384em 40px 1.384em 20px; padding: 0px 0px 0px 30px; vertical-align: baseline; quotes: none;">
<p style="border-width: 0px; background-color: transparent; font-size: 13px; margin: 0px 0px 0.692em; padding: 0px; vertical-align: baseline;"><b style="border-width: 0px; background-color: transparent; font-size: 13px; margin: 0px; padding: 0px; vertical-align: baseline;"><br>
<?php</b></p><p style="border-width: 0px; background-color: transparent; font-size: 13px; margin: 0px 0px 0.692em; padding: 0px; vertical-align: baseline;">function doctor_menu() {<br>$items = array();</p><p style="border-width: 0px; background-color: transparent; font-size: 13px; margin: 0px 0px 0.692em; padding: 0px; vertical-align: baseline;">
$items['doctor'] = array(<br>'title' => t('Doctors'),<br>'page callback' => 'doctors_list',<br>'access arguments' => array('access doctor'),<br>'type' => MENU_NORMAL_ITEM );<br>
$items['doctor/delete/%doctor_user'] = array(<br>'title' => t('Delete doctor'),<br>'page callback' => 'drupal_get_form',<br>'page arguments' => array('doctor_delete_confirm', 2),<br>
'access arguments' => array('access doctor'),<br>'type' => MENU_CALLBACK, );<br>$items['doctor/edit/%doctor_user'] = array(<br>'title' => t('Edit Form'),<br>'page callback' => 'drupal_get_form',<br>
'page arguments' => array('doctor_edit_confirm', 2),<br>'access arguments' => array('access doctor'),<br>'type' => MENU_NORMAL_ITEM,<br>);return $items;<br>}<br>function doctors_list() {<br>
$header = array(t('Doctor Name'), t('Gender'), t('Status'), t('Action'));<br>$query = "SELECT * FROM {doctor}";<br>$rs = db_query($query);<br>$row = array();<br>if ($rs) {<br>while ($data = db_fetch_object($rs)) {<br>
$gender = $data->gender;<br>$status = $data->status ;<br>$row[] = array(stripslashes(ucwords($data->firstname)) . ' ' . stripslashes(ucwords($data->lastname)), $gender, $status,<br>"<a style="border-width: 0px; background-color: transparent; font-size: 13px; margin: 0px; padding: 0px; vertical-align: baseline; color: rgb(6, 120, 190); text-decoration: none;">doctorid}'>" . t('Edit') . "</a><span> </span>|<span> </span><a style="border-width: 0px; background-color: transparent; font-size: 13px; margin: 0px; padding: 0px; vertical-align: baseline; color: rgb(6, 120, 190); text-decoration: none;">doctorid}'>" . t('Delete') . "</a>");<br>
}}<br>$str .= theme_table($header, $row);<br>return $str;<br>}<br>function doctor_user_load($doctorid) {<br>$query = "SELECT * FROM {doctor} WHERE doctorid = %d";<br>$rs = db_query($query, $doctorid);</p><p style="border-width: 0px; background-color: transparent; font-size: 13px; margin: 0px 0px 0.692em; padding: 0px; vertical-align: baseline;">
if ($rs) {<br>while ($data = db_fetch_object($rs)) {<br>return $data;<br>}}<br>return FALSE;<br>}<br>function doctor_delete_confirm(&$form_state, $doctor) {<br>$form['_doctor'] = array(<br>'#type' => 'value',<br>
'#value' => $doctor,);</p><p style="border-width: 0px; background-color: transparent; font-size: 13px; margin: 0px 0px 0.692em; padding: 0px; vertical-align: baseline;">return confirm_form($form,t('Are you sure you want to delete this doctor?'),<br>
isset($_GET['destination']) ? $_GET['destination'] : "doctor",t('This action cannot be undone.'),t('Delete'),t('Cancel'));}</p><p style="border-width: 0px; background-color: transparent; font-size: 13px; margin: 0px 0px 0.692em; padding: 0px; vertical-align: baseline;">
function doctor_delete_confirm_submit($form, &$form_state) {<br>$form_values = $form_state['values'];<br>if ($form_state['values']['confirm']) {<br>$doctor = $form_state['values']['_doctor'];</p>
<p style="border-width: 0px; background-color: transparent; font-size: 13px; margin: 0px 0px 0.692em; padding: 0px; vertical-align: baseline;">$query = "DELETE FROM {doctor} where doctorid=$doctor>doctorid";<br>
$rs = db_query($query);<br>drupal_set_message(t('Doctor has been deleted successfully.'));}<br>drupal_goto("doctor");<br>}<br>function doctor_edit_confirm(&$form_state,$doctor){</p><p style="border-width: 0px; background-color: transparent; font-size: 13px; margin: 0px 0px 0.692em; padding: 0px; vertical-align: baseline;">
$form = array();<br>$form['firstname']=array(<br>'#title'=>t('First Name'),<br>'#type'=>'textfield',<br>'#default_value' => $firstname );<br>$form['lastname']=array(<br>
'#title'=>t('Last Name'),<br>'#type'=>'textfield',<br>'#default_value' => $lastname);<br>$form['gender']=array(<br>'#title'=>t('Gender'),<br>'#type'=>'radios','#options' => array(t('male'), t('female')),<br>
'#default_value' => male);<br>$form['status']=array(<br>'#title'=>t('Status'),<br>'#type'=>'radios',<br>'#default_value' => active,<br>'#options' => array(t('active'), t('inactive')));<br>
return confirm_form($form,t(''),<br>isset($_GET['destination']) ? $_GET['destination'] : "doctor",<br>t(''),<br>t('Edit'),<br>t('Cancel'));}</p><p style="border-width: 0px; background-color: transparent; font-size: 13px; margin: 0px 0px 0.692em; padding: 0px; vertical-align: baseline;">
function doctor_edit_confirm_submit($form, &$form_state)<br>{<br>$form_values = $form_state['values'];<br>if ($form_state['values']['confirm']) {<br>$doctor = $form_state['values']['_doctors'];<br>
$query = "UPDATE {doctor} WHERE doctorid='$doctor->doctorid'";<br>} drupal_goto("doctor");}</p><p style="border-width: 0px; background-color: transparent; font-size: 13px; margin: 0px 0px 0.692em; padding: 0px; vertical-align: baseline;">
<span style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium;"><span style="font-family: arial; font-size: small;"><b><i style="color: rgb(0, 153, 0); font-family: 'comic sans ms',sans-serif;"><font style="color: rgb(0, 153, 0);" size="2">MAHESH GAJABAR</font></i><br style="color: rgb(0, 153, 0); font-family: 'comic sans ms',sans-serif;">
<font style="color: rgb(0, 153, 0); font-family: 'comic sans ms',sans-serif;" size="2"><i>Software Developer<br>FrontalRain Technologies,Bengaluru</i></font></b><br></span></span></p><p style="border-width: 0px; background-color: transparent; font-size: 13px; margin: 0px 0px 0.692em; padding: 0px; vertical-align: baseline;">
<br></p><p style="border-width: 0px; background-color: transparent; font-size: 13px; margin: 0px 0px 0.692em; padding: 0px; vertical-align: baseline;"><br></p></blockquote></span></span>
</blockquote></div><br><br clear="all"><br>-- <br>Randy Fay<br>Drupal Module and Site Development<br><a href="mailto:randy@randyfay.com">randy@randyfay.com</a><br>+1 970.462.7450<br><br>