Answer the question
In order to leave comments, you need to log in
Why doesn't yii define an additional safe attribute on a post request?
Good afternoon,
There is a Users model . In it, I included 2 properties not from the table
class Users extends CActiveRecord
{
public $test;
public $configsArray;
...
public function rules()
{
return
[
[['test','configsArray'],'safe'],
...
]
...
}
...
echo $form->checkBoxList($model, 'configsArray', CHtml::listData(ConfigUser::model()->findAll(), 'id', 'name'));?>
...
echo $form->textField($model, 'test');?>
...
...
if(isset($_POST['Users']))
{
$model->setAttributes($_POST['Users'],true);
My::printArr($model->configsArray);
My::printArr($model->test);
My::printArr($model->attributes);
die();
}
...
Array
(
[0] => 21
[1] => 23
)
test)))))))))))))))
Array
(
[id] => 7
[name] => Михаил Боярский
[role_id] => 1
[email] => [email protected]
[password] => 1b5e867a2e6bf3c45977b6a513b7af3e
[contacts] => +77775556677
[sys_date] =>
[sys_date_update] =>
[sys_user] =>
[exist] => 1
[status] => 1
[category_id] => 1
[photo_id] =>
[photo] =>
)
var_dump($model->getErrors());
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question