Many hidden fields generated


I have a CActiveForm I submit with GET.

When I come back on the page, after the submit, my form is filled with additional hidden fields, one for each field I had in the form the first time.

If I submit the form again, I send all those fields so the next I come back, my form is filled again with more hidden fields, and so on, the number of hidden fields grows up after each submit request.

Any idea why it happens ?


I’ve found hidden fields are generated my CHtml::beginForm()

if(!strcasecmp($method,'get') && ($pos=strpos($url,'?'))!==false)


    foreach(explode('&',substr($url,$pos+1)) as $pair)






I don’t see the point. Each time the form is submitted, there will be more and more hidden fields.

I don’t know the exact reason for it, but off the top of my head maybe is to ease the process of getting the GET parameters using javascript if you need to do so.

Also, perhaps they increase in every form submit cause you’re doing something wrong, like using the actual URL (which already has some get parameters defined) instead of a “clean” one to send the form.

I don’t see what I could do wrong. What I do if very basic.

I’ve opened an issue.

Related issue on GitHub -

Problem is in the way a GET request works - it adds to the url the input parameters with the values even if they are empty…

And as the documentation say if the action attribute is empty it uses the current URL - http://www.yiiframew…m#action-detail

So what happens is that the current url is used and all the input attributes are appended to it… and that happens every time you try to submit the form… this way on every submit the URL become bigger and bigger and those hidden fields are generated from the url…

The solution is to set the action attribute.