t('oxygen'), 'page callback' => 'oxygen_form', 'access arguments' => array(), 'access callback' => TRUE, 'description' => t('oxygen'), 'type' => MENU_CALLBACK, ); return $items; } function oxygen_form() { return drupal_get_form('oxygen_form1'); } function oxygen_form1($form, &$form_state) { $form = array(); $form['my_textfield'] = array( '#type' => 'textfield', '#title' => t('Name'), '#description' => t(''), '#weight' => 0, '#required' => TRUE, '#size' => 50, '#maxlength' => 20, '#ajax' => array( 'callback' => 'oxygen_form1_callback'), // 'method' => 'replace_textfield_div'), // 'effect' => 'fade',) ); $form['class']=array( '#type'=>'select', '#title' => t('class'), '#options' => array('1'=>'a','2'=>'b','3'=>'c','4'=>'d'), '#weight'=>1, '#required'=> TRUE, '#ajax' => array( 'callback' => 'oxygen_form1_callback', 'wrapper' => 'dropdown-second-replace') ); $form['section']=array( '#type'=>'select', '#title' => t('section'), '#options' => array('1'=>'u','2'=>'v','3'=>'w','4'=>'x'), '#weight'=>2, '#required'=> TRUE, '#ajax' => array( 'callback' => 'oxygen_form1_callback', 'wrapper' => 'dropdown-second-replace') ); $form['house']=array( '#type'=>'select', '#title' => t('House Name'), '#options' => array('1'=>'y','2'=>'z'), '#weight'=>3, '#required'=> TRUE, '#ajax' => array( 'callback' => 'oxygen_form1_callback', 'wrapper' => 'dropdown-Select') ); $form['Gender'] = array( '#type' => 'radios', '#title' => t('Select the gender'), '#description' => t(''), '#weight' =>'4', '#required'=> TRUE, '#attributes' => array('id'=>'radiob'), '#options' => array( t('Male'), t('Female'), t('other'), ) ); $form['date'] = array( '#type' => 'date', '#title' => t('Date'), // '#default_value'=>$date, '#attributes' => array('id'=>'datepicker'), '#weight' =>5, ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 6, ); return $form; } // function oxygen_form1_validate($form, &$form_state){ // if(empty($form_state['values']['my_textfield']) || // empty($form_state['values']['class']) || empty($form_state['values']['section']) || empty($form_state['values']['house']) || empty($form_state['values']['Gender']) // ){ // form_set_error('my_textfield',t('Please Select the Name!')); // } // } function oxygen_form1_submit($form, $form_state) { global $user; db_insert('oxygen_form1') ->fields(array( 'uid' => $user->uid, 'my_textfield' => $form_state['values']['my_textfield'], 'class' => $form_state['values']['class'], 'section' => $form_state['values']['section'], 'house' => $form_state['values']['house'], 'Gender' => $form_state['values']['Gender'], ))->execute(); drupal_set_message("successfully saved Data"); }