yii2 - Form not POST ing -


this view there form containig field , submit button.

<form id="typeheadform" method="post" class="form-horizontal">         <div class="form-group">             <label class="col-xs-3 control-label">movie</label>             <div class="col-xs-3">                 <input type="text" class="form-control" name="state" id="movie_name" />             </div>         </div>           <input type='submit' name='submit' value='search' class="btn btn-squared btn-default">     </form>  

and below controller code

  public function actionmovies_all()         {             $this->layout = "main";             if ( isset( $_post[ 'movie_name' ] ) )             {              print_r("success");die();             }             if ( yii::$app->request->post() )             {               print_r(yii::$app->request->post());die();             }         } 

i not able post form. doing wrong? getting error " bad request (#400) unable verify data submission."

replace <form id="typeheadform" method="post" class="form-horizontal">

<?= \yii\helpers\html::beginform('', 'post', ['id' => 'typeheadform', 'class' => 'form-horizontal']);?> 

you getting bad request because when create form manually, did not include csrf token it. when create form html::beginform method takes care internaly.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -