CModel set attribute problem

Hi, please forgive i am new to yii,

I want to save the $_POST result by CModel. and follow the example it is

$model->attributes = $_POST[‘User’];

OR

$model->setAttributes($_POST[‘User’]);

then

$model->save()

but i found there fields not saved if I didn’t put any rules in the model.

then i try to pass in safe attribute flag

$model->setAttributes($_POST[‘User’], false);

then i found it can save, but the captcha will have error.

sorry, i dont understand about this…

please help

Please, read this carefully: http://www.yiiframework.com/doc/guide/1.1/en/form.model#securing-attribute-assignments

For the massive assignment to work, you need to create a rule for the attributes, even if you’re just flagging all the attributes as ‘safe’.

You should really specify more details about what your inputs are though, to help ensure that you’re processing what you expect to process.

everyone, thanks. i understand. ::)

but why if i flag massive set attribute to false. the captcha will be affected? ???

To skip the captcha validation, you’d need to run $model->save(false);

I see, thank you so much everyone. esp dana.

have a nice day :)