The name attribute for every input element is resolved by method CHtml::resolveName.
It is in the following format.
public static function resolveName($model,&$attribute)
{
............................................
............................................
return get_class($model).'['.$attribute.']';
}
If you look at the form elements rendered by CHtml in firebug,
there is nothing surprising in what we are getting in $_POST.
As I understand,Yii used from parent class name of the $model(get_class in resolveName()) for beauty, and is not very necessary the parent class name of the $model. it’s right?
If you were to change it and Not make it array notation, you might make your life a lot harder, for example your controller ( or elsewhere ) code is going to have to change to reflect it.
For example, using the default example
$model = new User();
if( isset($_POST['User']) && is_array($_POST['User']) )
$model->attributes = $_POST['User'] // mass assignment
Without array notation you’d have to individually assign fields somehow.
So in a sense, this is function over beauty. ESPECIALLY when you have more then 1 form on the page - ex. a login form and a contact form need to be differentiated.
I understand your comments and have very thank you.
I just wanted to be sure the User model attributes in form initialization do not participate. And only the model name are used. The issue for me is resolved and now change name of this topic to a appropriate name.