开发者

form is not sumitting in drupal

form is not submitting,

function assertion_reason_menu()
      {
          $items['assertion_reason']=array(
                        'title'=>'assertion_reason',
                        'page callback'=>'drupal_get_form',
                        'page arguments'=>array('assertion_reason_form'),
            //            'type'=>MENU_CALLBACK,
                        'type'=>MENU_NORMAL_ITEM,
                    //    'access content'=>array('assertion_reason'),
                        //'access callback' => array('_assertion_reason_access'),
                        'access callback'=>TRUE,
                    );
          return $items;
      }
      function _assertion_reason_access($perm) {print_r('sdf');exit;
          return user_access($perm);
      }


     /**
      * Implementation hook_form
      */
     function assertion_reason_form()
     {
         /*$form['assertion_reason']=array(
                    '#type'=>'fieldset',

                    '#title'=>t('Assertion-Reason'),
                    '#description'=>t('Fill assertion and reason'),
                );*/
         $form['assertion']=array(
                    '#type'=>'textfield',
                    '#required'=>TRUE,
                    '#title'=>t('Assertion'),
                    '#description'=>t('Enter Assertion'),
                );
         $form['reason']=array(
                    '#type'=>'textfield',
                    '#title'=>t('Reason'),
                    '#required'=>TRUE,
                    '#description'=>t('Enter Reason'),
                );
         $form['submit']=array(
                    '#type'=>'submit',
                    '#value'=>t('submit'),
                    '#description'=>t('Submit assertion and reason'),
                );
                return $form;
     }

     function assertion_reason_form_submit($form_id,&$form_state)
     { 
         echo 'chetan';
        // $assertion=$form_state['values']['assertion'];
         //$reason=$form_state['values']['reason'];
      开发者_StackOverflow   //$timestamp=date('d/m/y H:M');
         //db_query("insert into {assertion_reason} values('%s','%s',%d,'%s')");
         drupal_set_message('You are filled assertion or reason');
     }


change the name of "assertion_reason_form" you shouldn't implement hook_form..the name of the function thet passed to drupal_get_form shouldn't be like hook_form...it should be different.. test the following code (i didn't test it) ...and don't forget to clear the cache

  function assertion_reason_menu()
  {
      $items['assertion_reason']=array(
                    'title'=>'assertion_reason',
                    'page callback'=>'drupal_get_form',
                    'page arguments'=>array('_my_new_test_form'),
        //            'type'=>MENU_CALLBACK,
                    'type'=>MENU_NORMAL_ITEM,
                //    'access content'=>array('assertion_reason'),
                    //'access callback' => array('_assertion_reason_access'),
                    'access callback'=>TRUE,
                );
      return $items;
  }
  function _assertion_reason_access($perm) {print_r('sdf');exit;
      return user_access($perm);
  }


 /**
  * its not the implemention of hook_form
  */
 function _my_new_test_form($form_state)
 {
     /*$form['assertion_reason']=array(
                '#type'=>'fieldset',

                '#title'=>t('Assertion-Reason'),
                '#description'=>t('Fill assertion and reason'),
            );*/
     $form['assertion']=array(
                '#type'=>'textfield',
                '#required'=>TRUE,
                '#title'=>t('Assertion'),
                '#description'=>t('Enter Assertion'),
            );
     $form['reason']=array(
                '#type'=>'textfield',
                '#title'=>t('Reason'),
                '#required'=>TRUE,
                '#description'=>t('Enter Reason'),
            );
     $form['submit']=array(
                '#type'=>'submit',
                '#value'=>t('submit'),
                '#description'=>t('Submit assertion and reason'),
            );
            return $form;
 }

 function _my_new_test_form_submit($form,&$form_state)
 { 
     echo 'chetan';
    // $assertion=$form_state['values']['assertion'];
     //$reason=$form_state['values']['reason'];
     //$timestamp=date('d/m/y H:M');
     //db_query("insert into {assertion_reason} values('%s','%s',%d,'%s')");
     drupal_set_message('You are filled assertion or reason');
 }


this form submits perfectly in my drupal install - as suggested clear your cache and try

function assertion_reason_menu() {
    $items['assertion_reason']=array(
        'title'=>'assertion_reason',
        'page callback'=>'drupal_get_form',
        'page arguments'=>array('assertion_reason_form'),
        'type'=>MENU_NORMAL_ITEM,
        'access callback'=>TRUE,
    );

    return $items;
}

/**
* Implementation hook_form
*/
function assertion_reason_form() {

    $form['assertion']=array(
        '#type'=>'textfield',
        '#required'=>TRUE,
        '#title'=>t('Assertion'),
        '#description'=>t('Enter Assertion'),
    );
    $form['reason']=array(
        '#type'=>'textfield',
        '#title'=>t('Reason'),
        '#required'=>TRUE,
        '#description'=>t('Enter Reason'),
    );
    $form['submit']=array(
        '#type'=>'submit',
        '#value'=>t('submit'),
        '#description'=>t('Submit assertion and reason'),
    );

    return $form;
}

function assertion_reason_form_submit($form_id,&$form_state) { 

    drupal_set_message('You are filled assertion or reason');
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜