basic question about $_POST[LoginForm]

Hi, guys

I’m new to both php and yii. so here’s a basic question about getting the POST data array submitted by a certern form.

suppose a simple login form:




<form action=login.php method=post name=LoginForm>

username:<input type=text name=username />

password:<input type=text name=password />

<input type=submit />

</form>



from many php tutorials, the $_POST data array should be $_POST(‘username’=>username, ‘password’=>password)

but from the yii guide, I found the $_POST seems to be more like $_POST(‘LoginForm’=>array(‘username’=>username, ‘password’=>password))

so my question is, do these two methods differ from the php version or some configuration?

my php version is 5.3 and yii is 1.1.4

thanks in advance

This is only a convention to make it easier to find the input elements that belong to a specific form. Check out the source code of forms created by Yii: All input elmements will have names like LoginForm[username] instead of username. So no special PHP configuration is required.

This is for the purpose of "massive assignment":

http://www.yiiframework.com/doc/guide/form.model#securing-attribute-assignments

thanks.

BTW, I didn’t use Yii’s Helper class to generate the form. Instead, I just used pure html code. So, no wonder how I searched with google but just cannot found the answer.

if i use my own code and don’t use this format, of course, i cannot use massive assignment. but can i use some kind of [single assignment] instead?

Of course you can. But then you loose some of Yii’s nice convenience features and some things might not work anymore or be harder to achieve… So - as you’re beginning with Yii - i’d advise not to do so. Is there any reason you don’t want to use it?

just because all the forms have been written before and i just wanna migerate them to the yii framework.

but maybe rewritten would be better. 3x 4 advice.