title: How to make controller remember ajax post data Yii2
body: <p>I have multi modal windows, from one of it i want to send few $models to another window its like father heve few sons... and we can't save sons because we don't know father id and name..</p>
  
  <p>JS</p>
  
  <pre><code>$("#modal-deposit").submit(function($form) {
  
      $form.preventDefault();
      $.ajax({
          type: "POST",
          url: "index.php?r=family/create", // сreatedeposit создает запись.
          data: $("#form-deposit").serialize(), // Сериализует the form's elements.
   return false;
  });
  </code></pre>
  
  <p>Action</p>
  
  <pre><code>public function actionCreate()
      {
          $family_model = new family();
          $model_deposit = new FinanceIncomeExpenses();
  
          if ($family_model-&gt;load(Yii::$app-&gt;request-&gt;post())
              &amp;&amp; $family_model-&gt;save())
          {
             if ($model_deposit-&gt;sum != null)// one of the required fields
              {
                 $model_deposit-&gt;family_id = $family_model-&gt;id;
                 $model_deposit-&gt;save();
              }
  
  
          } else {
              if(Yii::$app-&gt;getRequest()-&gt;isAjax){
                  return $this-&gt;renderAjax('create', [
                      'family_model' =&gt; $family_model,
                      'model_deposit' =&gt; $model_deposit,
                  ]);
              }else{
                  return $this-&gt;render('create', [
                      'family_model' =&gt; $family_model,
                      'model_deposit' =&gt; $model_deposit,
                  ]);
              }
          }
      }
  </code></pre>