CActiveForm - where is the $_POST['Post'] value set?


My question is about this piece of code:

    public function actionCreate()







So I have inherited one Controller class from another (as they have much in common, but cannot be the same class). Hierarchy is like this:

Controller //the one from yii





The QPostController uses ‘create’ action of it’s base class (PostController), and the code is like the one mentioned above. The problem is:

When I access (submit a form to) the PostController/create action, the values from the form are in $_POST[‘Post’], but

when I access QPostController/create action, the values from the form are in $_POST[‘QPost’]. I wold like the values to always be in $_POST[‘Post’]. Is it possible to do this?

The solution seems to be using:

$_POST[get_class($model)] instead of $_POST[‘Post’]


Hi edek!!

I’d like to advice you not to invest time in reusing the code of the controller. In my experience, the code if the controller is, yes, repetitive, but so simple that it don’t worth to be reused.

My approach to the controller is to write the shortest code possible, pushing all data process possible in the models and keep the controller the smallest possible.

This code you recicled is good for a create with exactly one model, right? And if you have 2 models? You should rewrite the function, no options.

My advice is not to recycle the code of the controller, but to extend Gii in order to generate the code more close to our need, this is a very good time investing.

Of corse is just an advice that came from a bit of experience, feel free to continue on your way, and, if you think that your approach has some advantages, please reply me, I’d like to try new ways!!