Hi all,
What´s the difference between $model->load and $model->attributes? I think both of them have the same behaviour but i suppose they will have a difference.
Thanks a lot,
Hi all,
What´s the difference between $model->load and $model->attributes? I think both of them have the same behaviour but i suppose they will have a difference.
Thanks a lot,
$model->attributes:
Returns the list of attribute names.
By default, this method returns all public non-static properties of the class. You may override this method to change the default behavior.
$model->load:
Populates the model with the data from end user.
The data to be loaded is $data[formName], where formName refers to the value of formName(). If formName() is empty, the whole $data array will be used to populate the model. The data being populated is subject to the safety check by setAttributes().
thanks
remember
$model->attributes = [some atrribs]
does attributes assignment.
Thanks to all.
But when yo do this assignment
$model->attributes = \Yii::$app->request->post(‘ContactForm’);
and you do
$model->load(Yii::$app->request->post())
Both of them populate the model with the data from end user, Am I wrong?
Thanks moginn
But with attributes method I only return safe properties, is it right?