Skip to content
Advertisement

Yii2 Multiple instances of the same model

I want to get multiplie instance of the same model in my controller. I saw this wiki for Yii 1.1 and tried like that but in my code only last instance in form was acceble from controller my code is here (I commented code with error and variable values):

JavaScript

It is my form view in _form.php:

JavaScript

It is log result for: Yii::info(Yii::$app->request->post(),’test’) in debugger as you seen only last DatePart available but I have two DatePart model instance (contractDate and contractExpirationDate):

JavaScript

Advertisement

Answer

Controller:

JavaScript

View Form:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement