Call to a member function isAttributeRequired() on array

I have this line of code in backend/views/index.php folder
<?= $form->field($models, 'end_date')->textInput(['class' => 'form-control my-datepicker','readonly' => 'readonly']) ?>

Here in my controllers I define $models as follow ;
class TourItemController extends Controller
public function actionIndex()
$models = TourItem::find()->all();
return $this->render(‘index’,[‘models’ => $models]);
When I run the index.php I got this error says: Call to a member function isAttributeRequired() on array. What should I do? I am new in yii and I am starting hate it :(( please help me

While ActiveForm::field() method takes a model object as the 1st parameter, you are supplying an array of model objects.

how can I do that?

I’m sorry, but I can’t say something helpful any more, because I don’t understand what you are trying to accomplish.

This article of the guide might be helpful, though.
Guide > Getting Data from User > Collecting tabular input

1 Like