How to pass two objects of the same form yii2?

Good day! Can't handle two objects of the same form.
The meaning of this. I have a model, it does not pull anything from the base, it's just a form with custom fields, in my case just two dates. But this form I'll use on multiple reports. So I create two objects of the same shape in the controller.
Here is the model:
<?php


namespace app\models;


use yii\base\Model;

class ReportsForm extends Model
{
 public $date_one;
 public $date_two;

 public function attributeLabels()
{
 return [
 'date_one' => 'start date',
 'date_two' => 'end date',
];
}

 public function rules(){
 return [
[['date_one','date_two'],'required'],
[['date_one','date_two'],'safe'],
];
}
}


Here is the controller:
public function actionEpicrisis(){
 $epicrisis = new ReportsForm(); // Form for Отчета1
 $analyzes = new ReportsForm(); // Form for Отчета2

 return $this->render('epicrisis',compact('epicrisis','analyzes'));
 } // Report processing

But the shooter
<h2 class="animated bounceInRight">REPORTS</h2>
 <h2>SELECT PARAMETERS</h2>
<hr>
 <?php $form = ActiveForm::begin([
'id'=>'report1'
])?>
 <?= $form->field($epicrisis,'date_one')->widget(DatePicker::class)?>
 <?= $form->field($epicrisis,'date_two')->widget(DatePicker::class)?>
 <?= Html::submitButton('Apply',['class' => 'btn btn-primary'])?>
 <?php $form = ActiveForm::end()?>

<hr>
 <?php $form1 = ActiveForm::begin([
'id'=>'report2'
])?>
 <?= $form1->field($analyzes,'date_one')->widget(DatePicker::class)?>
 <?= $form1->field($analyzes,'date_two')->widget(DatePicker::class)?>
 <?= Html::submitButton('Apply',['class' => 'btn btn-primary'])?>
 <?php $form1 = ActiveForm::end()?>
 <hr>

Further, these forms I turn in the action, but the second form does not work (it is below the code). That is, the first works and the second does not. If I comment the first form (It's action), the second works. What is the problem do not understand, help me understand.
I have two forms a simple widget date is, so here is the second form it doesn't work if forced to data to drive and press Apply, it fulfills the first form, although the data sent from the second
April 7th 20 at 15:50
1 answer
April 7th 20 at 15:52
Solution
Your problem name the form the Same. Ie output two forms.
Not to produce the same, you can use inheritance. Ie
ReportsForm
and
ReportsForm2 extend ReportsForm

$epicrisis = new ReportsForm(); // Form for Отчета1
$analyzes = new ReportsForm2(); // Form for Отчета2
Good afternoon.
The decision, to put it mildly, wrong. - Travis_Boehm9 commented on April 7th 20 at 15:55
All Your comments too so we can talk. Little to say is wrong, need to justify.
The person asked the question, as the page to display TWO forms. Not one.
<form id="report1"></form>
and
<form id="report2"></form>

And I understand that they are always the same.
The forms must be different
name
. So this was the easiest to Use inheritance(if we take into account that they should be the same or with the same common parts), if the shape is completely different, using two separate forms. - Prudence86 commented on April 7th 20 at 15:58
Naturally in the view for each form to prescribe a different action. - Prudence86 commented on April 7th 20 at 16:01
@keara.Nol, Well, I think the way it is, very logically, the names of the forms I have not changed, it is for this reason, all flew not to where I planned, now I decided, just didn't want to produce I the same shape, but I had to when I optimize the code I will try your solution. Thank you - marietta.Satterfie commented on April 7th 20 at 16:04

Find more questions by tags Yii