Answer the question
In order to leave comments, you need to log in
Why does Call to a member function isAttributeRequired() on array throw an error?
Good afternoon! Tell me, what is the error Call to a member function isAttributeRequired() on array?
view
$form = ActiveForm::begin();
echo $form->field($modelPagesOnList, 'state_22')->dropDownList([
'0' => 'Активный',
'1' => 'Отключен',
'2'=>'Удален'
]);
ActiveForm::end();
class PagesOnList extends Model
{
public $state_22;
public function rules()
{
return [
[['state_22'], 'required'],
];
}
public function attributeLabels()
{
return array(
'state_22'=>$this->state_22
);
}
}
$modelPagesOnList = new PagesOnList();
$modelPagesOnList->attributes = Yii::$app->request->post('PagesOnList');
print_r($modelPagesOnList->state_22);
....
return $this->render('index', ['modelPagesOnList'=>$modelPagesOnList]);
Answer the question
In order to leave comments, you need to log in
public function attributeLabels()
{
return array(
'state_22'=>$this->state_22
);
}
$modelPagesOnList->load(Yii::$app->request->post('PagesOnList'))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question