megabr
(Megabr)
1
hello,
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
beginForm('','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 ( ))

qiang
(Qiang Xue)
2
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.
megabr
(Megabr)
3
mmm not sucess:
current url:
/index.php?r=admin/user/search
form:
<?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:
/index.php?kw=teste&yt0=search
what I doing wrong 
qiang
(Qiang Xue)
4
As I said, the GET parameters in the URL will be discarded. You need to add a hidden field to store the 'r' parameter.
megabr
(Megabr)
5
sorry…
working now…!
<input type="hidden" name="r" value="admin/user/search">
the url is now:
/index.php?r=admin%2Fuser%2Fsearch&kw=teste&yt0=Search
thats is good?