title: yii2 form into modal and rendering submit into the same modal
body: <p>I have a form into a modal with a single 'new item' text input, a list of items and a submit button in it. Everything works perfectly, but I would like just after submitting to render again the same page (than has been updated) inside the same modal. Instead of thant it opens in the entire browser. I want all the operations to happen into the modal. All the examples I found seem to take the target out of the modal.</p>
  
  <p>I've tried with renderAjax instead of render after saving this way ...</p>
  
  <pre><code>if ($model-&gt;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;save()) {
      return $this-&gt;renderAjax('listar', [
          'searchModel' =&gt; $searchModel,
          'dataProvider' =&gt; $dataProvider,
          'pages' =&gt; $pages,
          'model' =&gt; $model
      ]);
  } else {
      return $this-&gt;renderAjax('listar', [
          'searchModel' =&gt; $searchModel,
          'dataProvider' =&gt; $dataProvider,
          'pages' =&gt; $pages,
          'model' =&gt; $model
      ]);
  }
  </code></pre>
  
  <p>(That means deleting condition, I know.)</p>
  
  <p>My view:</p>
  
  <pre><code>&lt;div class="incidencias-listar"&gt;
  
      &lt;?
      Pjax::begin([
          'enablePushState' =&gt; false,
          'id' =&gt; uniqid('pjax_') 
      ]);
      ?&gt; 
  
      &lt;div class="row"&gt;
  
          &lt;div class="col-sm-12 col-md-12 col-lg-12"&gt;
  
              &lt;div class="incidencias-form"&gt;
  
                  &lt;?
                  $form = ActiveForm::begin();
                  ?&gt;
  
                  &lt;?
                  echo $form-&gt;field($model, 'inc_descripcion')-&gt;textInput([
                      'maxlength' =&gt; true,
                      'tabindex' =&gt; '1' 
                  ])-&gt;label('Descripción');
                  ?&gt;
  
                  &lt;div class="form-group"&gt;
                      &lt;?= Html::submitButton('Añadir', ['class' =&gt; 'btn btn-primary'])?&gt;
                  &lt;/div&gt;
  
                  &lt;?php ActiveForm::end(); ?&gt;
  
              &lt;/div&gt;
  
          &lt;/div&gt;
  
      &lt;/div&gt;
  
      &lt;?
      echo ListView::widget([
          'dataProvider' =&gt; $dataProvider,
          'id' =&gt; uniqid('listview'),
          'options' =&gt; [
              'tag' =&gt; 'div',
              'class' =&gt; 'list-wrapper',
              'id' =&gt; 'list-wrapper' 
          ],
          'layout' =&gt; '&lt;div class="row paginador"&gt;{pager}&lt;/div&gt;&lt;div class="row"&gt;{summary}&lt;/div&gt;&lt;div&gt;{items}&lt;/div&gt;',
          'summary' =&gt; "&lt;div class=\"col-sm-12 col-md-12 col-lg-12\"&gt;&lt;div class=\"pull-left\"&gt;&lt;br/&gt;Mostrando &lt;b&gt;{begin}&lt;/b&gt;-&lt;b&gt;{end}&lt;/b&gt; de &lt;b&gt;{totalCount}&lt;/b&gt; incidencias.&lt;br/&gt;&lt;br/&gt;&lt;/div&gt;&lt;/div&gt;",
  
          'itemView' =&gt; function ($model, $key, $index, $widget) {
              return $this-&gt;render('_list_item', [
                  'model' =&gt; $model 
              ]);
          },
          'itemOptions' =&gt; [
              'class' =&gt; 'item' 
          ] 
      ]);
      ?&gt;
  
      &lt;? Pjax::end(); ?&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>I've also tried to create another ajax event fired by the inner submit button to display target into another modal.</p>
  
  <p>Tried many choices without luck.</p>