title: Form doesn't get submitted in yii2
body: <p>I'm using yii2 advanced app and im stuck at a point where my form doesn't get submitted. It refreshes and stays on the same page. There are no errors shown too. </p>
  
  <p>Here is the model code Countries.php</p>
  
  <pre><code>&lt;?php
  
  namespace backend\models\base;
  
  use Yii;
  use yii\behaviors\TimestampBehavior;
  use yii\behaviors\BlameableBehavior;
  use mootensai\behaviors\UUIDBehavior;
  
  /**
   * This is the base model class for table "countries".
   *
   * @property integer $id
   * @property string $sortname
   * @property string $name
   * @property integer $phonecode
   * @property integer $created_at
   * @property integer $updated_at
   * @property integer $created_by
   * @property integer $updated_by
   * @property integer $deleted_at
   * @property integer $deleted_by
   *
   * @property \backend\models\States[] $states
   */
  class Countries extends \yii\db\ActiveRecord
  {
      use \mootensai\relation\RelationTrait;
  
      private $_rt_softdelete;
      private $_rt_softrestore;
  
      public function __construct(){
          parent::__construct();
          $this-&gt;_rt_softdelete = [
              'deleted_by' =&gt; \Yii::$app-&gt;user-&gt;id,
              'deleted_at' =&gt; date('Y-m-d H:i:s'),
          ];
          $this-&gt;_rt_softrestore = [
              'deleted_by' =&gt; 0,
              'deleted_at' =&gt; date('Y-m-d H:i:s'),
          ];
      }
  
      /**
      * This function helps \mootensai\relation\RelationTrait runs faster
      * @return array relation names of this model
      */
      public function relationNames()
      {
          return [
              'states'
          ];
      }
  
      /**
       * @inheritdoc
       */
      public function rules()
      {
          return [
              [['sortname', 'name', 'phonecode'], 'required'],
              [['phonecode', 'created_at', 'updated_at', 'created_by', 'updated_by', 'deleted_at', 'deleted_by'], 'integer'],
              [['sortname'], 'string', 'max' =&gt; 3],
              [['name'], 'string', 'max' =&gt; 150],
              [['lock'], 'default', 'value' =&gt; '0'],
              [['lock'], 'mootensai\components\OptimisticLockValidator']
          ];
      }
  
      /**
       * @inheritdoc
       */
      public static function tableName()
      {
          return 'countries';
      }
  
      /**
       *
       * @return string
       * overwrite function optimisticLock
       * return string name of field are used to stored optimistic lock
       *
       */
      public function optimisticLock() {
          return 'lock';
      }
  
      /**
       * @inheritdoc
       */
      public function attributeLabels()
      {
          return [
              'id' =&gt; Yii::t('app', 'ID'),
              'sortname' =&gt; Yii::t('app', 'Sortname'),
              'name' =&gt; Yii::t('app', 'Name'),
              'phonecode' =&gt; Yii::t('app', 'Phonecode'),
          ];
      }
  
  
  
      /**
       * @return \yii\db\ActiveQuery
       */
      public function getStates()
      {
          return $this-&gt;hasMany(\backend\models\States::className(), ['country_id' =&gt; 'id']);
      }
  
      /**
       * @inheritdoc
       * @return array mixed
       */
      public function behaviors()
      {
          return [
              'timestamp' =&gt; [
                  'class' =&gt; TimestampBehavior::className(),
                  'createdAtAttribute' =&gt; 'created_at',
                  'updatedAtAttribute' =&gt; 'updated_at',
                  'value' =&gt; new \yii\db\Expression('NOW()'),
              ],
              'blameable' =&gt; [
                  'class' =&gt; BlameableBehavior::className(),
                  'createdByAttribute' =&gt; 'created_by',
                  'updatedByAttribute' =&gt; 'updated_by',
              ],
              'uuid' =&gt; [
                  'class' =&gt; UUIDBehavior::className(),
                  'column' =&gt; 'id',
              ],
          ];
      }
  
  
      /**
       * @inheritdoc
       * @return \backend\models\query\CountriesQuery the active query used by this AR class.
       */
      public static function find()
      {
          $query = new \backend\models\query\CountriesQuery(get_called_class());
          return $query-&gt;where(['countries.deleted_by' =&gt; 0]);
      }
  }
  </code></pre>
  
  <p>And the controller CountriesController.php</p>
  
  <pre><code>&lt;?php
  
  namespace backend\controllers;
  
  use Yii;
  use backend\models\Countries;
  use backend\models\search\CountriesSearch;
  use backend\controllers\BackendController;
  use yii\web\NotFoundHttpException;
  use yii\filters\VerbFilter;
  
  
  /**
   * CountriesController implements the CRUD actions for Countries model.
   */
  class CountriesController extends BackendController
  {
      public function behaviors()
      {
          return [
              'verbs' =&gt; [
                  'class' =&gt; VerbFilter::className(),
                  'actions' =&gt; [
                      'delete' =&gt; ['post'],
                  ],
              ],
              'access' =&gt; [
                  'class' =&gt; \yii\filters\AccessControl::className(),
                  'rules' =&gt; [
                      [
                          'allow' =&gt; true,
                          'actions' =&gt; ['index', 'view', 'create', 'update', 'delete', 'pdf', 'save-as-new','add-states'],
                          'roles' =&gt; ['admin']
                      ],
                      [
                          'allow' =&gt; false
                      ]
                  ]
              ]
          ];
      }
  
      /**
       * Lists all Countries models.
       * @return mixed
       */
      public function actionIndex()
      {
          $searchModel = new CountriesSearch();
          $dataProvider = $searchModel-&gt;search(Yii::$app-&gt;request-&gt;queryParams);
  
          return $this-&gt;render('index', [
              'searchModel' =&gt; $searchModel,
              'dataProvider' =&gt; $dataProvider,
          ]);
      }
  
      /**
       * Displays a single Countries model.
       * @param integer $id
       * @return mixed
       */
      public function actionView($id)
      {
          $model = $this-&gt;findModel($id);
  
          $providerStates = new \yii\data\ArrayDataProvider([
              'allModels' =&gt; $model-&gt;states,
          ]);
          return $this-&gt;render('view', [
              'model' =&gt; $this-&gt;findModel($id),
              'providerStates' =&gt; $providerStates,
          ]);
      }
  
      /**
       * Creates a new Countries model.
       * If creation is successful, the browser will be redirected to the 'view' page.
       * @return mixed
       */
      public function actionCreate()
      {
          $model = new Countries();
  
          if ($model-&gt;loadAll(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;saveAll()) {
              return $this-&gt;redirect(['view', 'id' =&gt; $model-&gt;id]);
          } else {
              return $this-&gt;render('create', [
                  'model' =&gt; $model,
              ]);
          }
      }
  
      /**
       * Updates an existing Countries model.
       * If update is successful, the browser will be redirected to the 'view' page.
       * @param integer $id
       * @return mixed
       */
      public function actionUpdate($id)
      {
          if (Yii::$app-&gt;request-&gt;post('_asnew') == '1') {
              $model = new Countries();
          }else{
              $model = $this-&gt;findModel($id);
          }
  
          if ($model-&gt;loadAll(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;saveAll()) {
              return $this-&gt;redirect(['view', 'id' =&gt; $model-&gt;id]);
          } else {
              return $this-&gt;render('update', [
                  'model' =&gt; $model,
              ]);
          }
      }
  
      /**
       * Deletes an existing Countries model.
       * If deletion is successful, the browser will be redirected to the 'index' page.
       * @param integer $id
       * @return mixed
       */
      public function actionDelete($id)
      {
          $this-&gt;findModel($id)-&gt;deleteWithRelated();
  
          return $this-&gt;redirect(['index']);
      }
  
      /**
       * 
       * Export Countries information into PDF format.
       * @param integer $id
       * @return mixed
       */
      public function actionPdf($id) {
          $model = $this-&gt;findModel($id);
          $providerStates = new \yii\data\ArrayDataProvider([
              'allModels' =&gt; $model-&gt;states,
          ]);
  
          $content = $this-&gt;renderAjax('_pdf', [
              'model' =&gt; $model,
              'providerStates' =&gt; $providerStates,
          ]);
  
          $pdf = new \kartik\mpdf\Pdf([
              'mode' =&gt; \kartik\mpdf\Pdf::MODE_CORE,
              'format' =&gt; \kartik\mpdf\Pdf::FORMAT_A4,
              'orientation' =&gt; \kartik\mpdf\Pdf::ORIENT_PORTRAIT,
              'destination' =&gt; \kartik\mpdf\Pdf::DEST_BROWSER,
              'content' =&gt; $content,
              'cssFile' =&gt; '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
              'cssInline' =&gt; '.kv-heading-1{font-size:18px}',
              'options' =&gt; ['title' =&gt; \Yii::$app-&gt;name],
              'methods' =&gt; [
                  'SetHeader' =&gt; [\Yii::$app-&gt;name],
                  'SetFooter' =&gt; ['{PAGENO}'],
              ]
          ]);
  
          return $pdf-&gt;render();
      }
  
      /**
      * Creates a new Countries model by another data,
      * so user don't need to input all field from scratch.
      * If creation is successful, the browser will be redirected to the 'view' page.
      *
      * @param mixed $id
      * @return mixed
      */
      public function actionSaveAsNew($id) {
          $model = new Countries();
  
          if (Yii::$app-&gt;request-&gt;post('_asnew') != '1') {
              $model = $this-&gt;findModel($id);
          }
  
          if ($model-&gt;loadAll(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;saveAll()) {
              return $this-&gt;redirect(['view', 'id' =&gt; $model-&gt;id]);
          } else {
              return $this-&gt;render('saveAsNew', [
                  'model' =&gt; $model,
              ]);
          }
      }
  
      /**
       * Finds the Countries model based on its primary key value.
       * If the model is not found, a 404 HTTP exception will be thrown.
       * @param integer $id
       * @return Countries the loaded model
       * @throws NotFoundHttpException if the model cannot be found
       */
      protected function findModel($id)
      {
          if (($model = Countries::findOne($id)) !== null) {
              return $model;
          } else {
              throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));
          }
      }
  
  
  
      /**
      * Action to load a tabular form grid
      * for States
      * @author Yohanes Candrajaya &lt;moo.tensai@gmail.com&gt;
      * @author Jiwantoro Ndaru &lt;jiwanndaru@gmail.com&gt;
      *
      * @return mixed
      */
      public function actionAddStates()
      {
          if (Yii::$app-&gt;request-&gt;isAjax) {
              $row = Yii::$app-&gt;request-&gt;post('States');
              if((Yii::$app-&gt;request-&gt;post('isNewRecord') &amp;&amp; Yii::$app-&gt;request-&gt;post('_action') == 'load' &amp;&amp; empty($row)) || Yii::$app-&gt;request-&gt;post('_action') == 'add')
                  $row[] = [];
              return $this-&gt;renderAjax('_formStates', ['row' =&gt; $row]);
          } else {
              throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));
          }
      }
  }
  </code></pre>
  
  <p>and the view file create.php</p>
  
  <pre><code>&lt;?php
  
  use yii\helpers\Html;
  
  
  /* @var $this yii\web\View */
  /* @var $model backend\models\Apps */
  
  $this-&gt;title = Yii::t('app', 'Create Apps');
  ?&gt;
  &lt;div class="uk-container uk-container-small uk-position-relative"&gt;
      &lt;div&gt;&lt;!----&gt; &lt;div&gt;
      &lt;h1 id="navbar" class="uk-h2 tm-heading-fragment"&gt;
          &lt;a href="#navbar"&gt;Apps&lt;/a&gt;
      &lt;/h1&gt;
  
      &lt;!-- Start Breadcrumb --&gt;
      &lt;ul class="uk-breadcrumb"&gt;
          &lt;li&gt;&lt;?= Html::a('Admin', ['/'])?&gt;&lt;/li&gt;
          &lt;li&gt;&lt;?= Html::a('Apps', ['/apps'])?&gt;&lt;/li&gt;
          &lt;li&gt;Create&lt;/li&gt;
      &lt;/ul&gt;
      &lt;!-- End Breadcrumb --&gt;
  
      &lt;?= $this-&gt;render('_form', [
          'model' =&gt; $model,
      ]) ?&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>and view _form.php</p>
  
  <pre><code>&lt;?php
  
  use yii\helpers\Html;
  use yii\widgets\ActiveForm;
  use alexeevdv\widget\SluggableInputWidget;
  use dosamigos\ckeditor\CKEditor;
  
  /* @var $this yii\web\View */
  /* @var $model backend\models\Apps */
  /* @var $form yii\widgets\ActiveForm */
  
  ?&gt;
  
  &lt;div class="uk-margin-auto"&gt;
  
      &lt;?php $form = ActiveForm::begin(); ?&gt;
  
      &lt;?= $form-&gt;errorSummary($model); ?&gt;
  
  
      &lt;?= $form-&gt;field($model, 'title')-&gt;textInput(['maxlength' =&gt; true, 'placeholder' =&gt; 'Title']) ?&gt;
  
      &lt;?= $form-&gt;field($model, 'slug')-&gt;widget(SluggableInputWidget::className(), [
          'dependsOn' =&gt; 'title',    
      ]); ?&gt;
  
      &lt;?= $form-&gt;field($model, 'content')-&gt;widget(CKEditor::className(), [
          'options' =&gt; ['rows' =&gt; 6],
          'preset' =&gt; 'basic',
          'clientOptions' =&gt; [
              'filebrowserImageBrowseUrl' =&gt; yii\helpers\Url::to(['imagemanager/manager', 'view-mode'=&gt;'iframe', 'select-type'=&gt;'ckeditor']),
          ]
      ]);?&gt;
  
      &lt;?= $form-&gt;field($model, 'video')-&gt;textInput(['maxlength' =&gt; true, 'placeholder' =&gt; 'Video']) ?&gt;
  
      &lt;?= $form-&gt;field($model, 'category')-&gt;widget(\kartik\widgets\Select2::classname(), [
          'data' =&gt; \yii\helpers\ArrayHelper::map(\backend\models\Categories::find()-&gt;orderBy('id')-&gt;asArray()-&gt;all(), 'id', 'name'),
          'options' =&gt; ['placeholder' =&gt; Yii::t('app', 'Choose a category')],
          'pluginOptions' =&gt; [
              'allowClear' =&gt; true
          ],
      ]); ?&gt;
  
      &lt;?= $form-&gt;field($model, 'status')-&gt;textInput(['placeholder' =&gt; 'Status']) ?&gt;
  
      &lt;div class="form-group"&gt;
      &lt;?php if(Yii::$app-&gt;controller-&gt;action-&gt;id != 'save-as-new'): ?&gt;
          &lt;?= Html::submitButton($model-&gt;isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' =&gt; $model-&gt;isNewRecord ? 'btn uk-button uk-button-primary' : 'btn uk-button uk-button-primary']) ?&gt;
      &lt;?php endif; ?&gt;
      &lt;?php if(Yii::$app-&gt;controller-&gt;action-&gt;id != 'create'): ?&gt;
          &lt;?= Html::submitButton(Yii::t('app', 'Save As New'), ['class' =&gt; 'btn uk-button uk-button-default', 'value' =&gt; '1', 'name' =&gt; '_asnew']) ?&gt;
      &lt;?php endif; ?&gt;
          &lt;?= Html::a(Yii::t('app', 'Cancel'), Yii::$app-&gt;request-&gt;referrer , ['class'=&gt; 'btn uk-button uk-button-danger']) ?&gt;
      &lt;/div&gt;
  
      &lt;?php ActiveForm::end(); ?&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>I've browsed few articles, but of no help. My form has a <code>&lt;?php ActiveForm::end(); ?&gt;</code> at the end of the form. I also tried to remove the select2 widget but i still get the same issue. Could someone help me out why this is happening?</p>
  
  <p>Html output rendered of create.php</p>
  
  <pre><code>&lt;div class="uk-container uk-container-small uk-position-relative"&gt;
      &lt;div&gt;&lt;!----&gt; &lt;div&gt;
      &lt;h1 id="navbar" class="uk-h2 tm-heading-fragment"&gt;
          &lt;a href="#navbar"&gt;Countries&lt;/a&gt;
      &lt;/h1&gt;
  
      &lt;!-- Start Breadcrumb --&gt;
      &lt;ul class="uk-breadcrumb"&gt;
          &lt;li&gt;&lt;a href="/final/backend/en-us"&gt;Admin&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="/final/backend/en-us/countries"&gt;Countries&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;Create&lt;/li&gt;
      &lt;/ul&gt;
      &lt;!-- End Breadcrumb --&gt;
  
  
  &lt;div class="uk-margin-auto"&gt;
  
      &lt;form id="w0" action="/final/backend/en-us/countries/create" method="post"&gt;
  &lt;input type="hidden" name="_csrf" value="zIvM0awWY3XpcrF1kY6gFY00ghnL1cgwTYhaEqF7RO2hch4x5AznMwtfWxWp4D-YW9yJy5aiNupb0JnMSbi5qQ=="&gt;
      &lt;div class="error-summary" style="display:none"&gt;&lt;p&gt;Please fix the following errors:&lt;/p&gt;&lt;ul&gt;&lt;/ul&gt;&lt;/div&gt;
      &lt;div class="form-group field-countries-id"&gt;
  &lt;input type="text" id="countries-id" class="form-control" name="Countries[id]" style="display:none"&gt;
  &lt;/div&gt;
      &lt;div class="form-group field-countries-sortname required"&gt;
  &lt;label class="control-label" for="countries-sortname"&gt;Sortname&lt;/label&gt;
  &lt;input type="text" id="countries-sortname" class="form-control" name="Countries[sortname]" maxlength="3" placeholder="Sortname" aria-required="true"&gt;
  
  &lt;div class="help-block"&gt;&lt;/div&gt;
  &lt;/div&gt;
      &lt;div class="form-group field-countries-name required"&gt;
  &lt;label class="control-label" for="countries-name"&gt;Name&lt;/label&gt;
  &lt;input type="text" id="countries-name" class="form-control" name="Countries[name]" maxlength="150" placeholder="Name" aria-required="true"&gt;
  
  &lt;div class="help-block"&gt;&lt;/div&gt;
  &lt;/div&gt;
      &lt;div class="form-group field-countries-phonecode required"&gt;
  &lt;label class="control-label" for="countries-phonecode"&gt;Phonecode&lt;/label&gt;
  &lt;input type="text" id="countries-phonecode" class="form-control" name="Countries[phonecode]" placeholder="Phonecode" aria-required="true"&gt;
  
  &lt;div class="help-block"&gt;&lt;/div&gt;
  &lt;/div&gt;
      &lt;div id="w3-container" class=" tabs-above tab-align-left tabs-krajee"&gt;&lt;ul id="w3" class="nav nav-tabs nav nav-tabs hidden-print" data-krajee-tabsx="tabsX_0b4b2adf" role="tablist"&gt;&lt;li class="active"&gt;&lt;a href="#w3-tab0" data-toggle="tab" role="tab"&gt;&lt;i class="glyphicon glyphicon-book"&gt;&lt;/i&gt; States&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
  &lt;div class="tab-content printable"&gt;&lt;div class="h3 visible-print-block"&gt;&lt;i class="glyphicon glyphicon-book"&gt;&lt;/i&gt; States&lt;/div&gt;
  &lt;div id="w3-tab0" class="tab-pane fade in active"&gt;&lt;div class="form-group" id="add-states"&gt;
  &lt;div id="w1" class="grid-view hide-resize" data-krajee-grid="kvGridInit_7fee31f2"&gt;&lt;div class="panel panel-default"&gt;
  
  
      &lt;div class="rc-handle-container" style="width: 628px;"&gt;&lt;div class="rc-handle" style="left: 50px; height: 37px;"&gt;&lt;/div&gt;&lt;div class="rc-handle" style="left: 496px; height: 37px;"&gt;&lt;/div&gt;&lt;/div&gt;&lt;div id="w1-container" class="table-responsive kv-grid-container"&gt;&lt;table class="kv-grid-table table table-hover kv-table-wrap"&gt;&lt;thead&gt;
  
  &lt;tr&gt;&lt;th class="kv-align-center kv-align-middle" style="width: 7.96%;" data-col-seq="0"&gt;#&lt;/th&gt;&lt;th class="kv-align-top kv-grid-hide" data-col-seq="1"&gt;Id&lt;/th&gt;&lt;th class="kv-align-top" data-col-seq="2" style="width: 71.02%;"&gt;Name&lt;/th&gt;&lt;th class="kv-align-middle" data-col-seq="3" style="width: 21.02%;"&gt;&lt;/th&gt;&lt;/tr&gt;
  
  &lt;/thead&gt;
  &lt;tbody&gt;
  &lt;tr&gt;&lt;td colspan="4"&gt;&lt;div class="empty"&gt;No results found.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
      &lt;div class="kv-panel-after"&gt;&lt;button type="button" class="btn btn-success kv-batch-create" onclick="addRowStates()"&gt;&lt;i class="fa fa-plus"&gt;&lt;/i&gt;Add States&lt;/button&gt;&lt;/div&gt;
  
  &lt;/div&gt;&lt;/div&gt;    &lt;/div&gt;
  
  
  &lt;/div&gt;
  &lt;/div&gt;&lt;/div&gt;    &lt;div class="form-group"&gt;
              &lt;button type="submit" class="uk-button uk-button-primary"&gt;Create&lt;/button&gt;                &lt;a class="uk-button uk-button-danger"&gt;Cancel&lt;/a&gt;    &lt;/div&gt;
  
      &lt;/form&gt;
  &lt;/div&gt;
  
  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>