is Gii CRUD generator code not following best practices?

I’ve recently been acquainted to CHttpRequest accessible with Yii:app()->request.

Gii’s generated crud code, for some actions methods in a stock controller, includes:




...

if(isset($_GET['Model']))

  $model->attributes=$_GET['Model'];

...



I wondered why it doesn’t use the request object’s getParam() method (or getQuery(), getPost()).

It looks like its worth the update. Maybe Gii wasn’t updated to use this utility class?

If needed to, i’ll open a bug on this but I wanted to make sure I didn’t miss anything.

getParam() can return just one parameter… .and you need to "know" which parameter you want…

on the other side check the source to see what setAttributes() does (this is called on the like $this->attributes = …) - http://www.yiiframework.com/doc/api/1.1/CModel#setAttributes-detail

There’s no problem using CHttpRequest::getParam() to get a single param which is an array, just like done when using _POST or _GET. You get the same thing in your hand:




Yii::app()->request->getParam('Modelname')



and




$_POST['Modelname'];



Are the same… .

Only that the former is more portable and (arguably) cleaner. If the two are equivalent, then whatever is done in setAttributes() is irrelevant.

This is surely not a significant issue but I guess its worth the fix, to maintain and enhance Yii’s “Professional” mission statement.