about this CHtml::beginForm();

I am trying use the search example from Qiang;

using the $_GET vars, but when change the fom submit method, from default post to GET, have one issue;

<?php echo CHtml::beginForm([??????????],'get'); ?>

when put get


form is posting to root web server;

any ideias about get the current url to put here?

<?php echo CHtml::beginForm(Yii:CPagination::getCurrentPage(),'get'); ?>

not work…

why by default not use in this function

beginForm(['post' or 'get' by defaul 'post'],action,options)?

public static string form(mixed $action='', string $method='post', array $htmlOptions=array ( )) 


Use '' should be fine. Internally, it would be translated to Yii::app()->getRequest()->getUrl()

Note, when you are using GET method, the GET parameters in the action URL are ignored (by HTTP spec). So you may need to put them into hidden fields.

mmm not sucess:

current url:



<?php echo CHtml::beginForm(Yii::app()->getRequest()->getUrl(),'GET'); ?>

<input type="text" name="kw" value="" autocomplete="off">

<?php echo CHtml::submitButton('search'); ?>

<?php echo CHtml::endForm(); ?>

after submit:


what I doing wrong :(

As I said, the GET parameters in the URL will be discarded. You need to add a hidden field to store the 'r' parameter.


working now…!

<input type="hidden" name="r" value="admin/user/search">

the url is now:


thats is good?