How to process forms no created using yii?

I’m experimenting with creating my own forms in html because I feel it gives me more control. I’ve created my form with fields like “fname” and “sname” etc. In Zend in order to send all the values to my model you can extract everything using:


$params = $this->_request->getParams();

then simply pass $params to the model.

I found that yii has this way of doing it:


if(isset($_POST['LoginForm']))

    $model->attributes=$_POST['LoginForm'];

However, that seems to only work for forms created using yii which put all data into the LoginForm[value] array.

Does yii have an equivalent to this?


$params = $this->_request->getParams();

What is the best way to extract all the variables and send them to my model?

Is creating my own forms “manually” so stupid that I absolutely shouldn’t do it? I’m new so please don’t beat me, I’m trying… :unsure:

Thanks for your time

Just use the $_POST array directly???

For an OO approach look here:

http://www.yiiframework.com/doc/api/1.1/CHttpRequest

I have changed the naming of my form fields to be compliant with how yii names them (in an array) so I have it working. I am still curious though. I can’t figure out how to use CHttpRequest. I thought this would give me what I want:


$param = CHttpRequest::getPost();

but it’s a non static method.

I’d be grateful if anybody could elaborate on the CHttpRequest. I’m also waiting for somebody to tell me that I absolutely shouldn’t make my own forms…

Thanks again

I won’t judge you too much for making your own forms… except that Yii’s active forms have SO MUCH more that you get for free (client/ajax/server validation, massive assignment, scenarios, etc). But anyway…

Try:

Yii::app()->getPost();

Yii::app()->getPost(); didn’t work:

At this point my interest is academic more than anything else. I’ve played around more with yii’s forms and I think we can become friends after all. In order to use my own forms I can simply put the names of the fields into a format that is compatible with standard yii procedure.