fibler
(Shaneog)
October 28, 2009, 9:20pm
1
I was just wondering if anyone knows a way to have a dropDownList auto submit and keep the url search engine friendly?
this is my code… it work but uses ?id=1 instead of /id/1
CHtml::dropDownList('id', $select, $list, array('onchange'=>'this.form.submit()'))
fibler
(Shaneog)
October 28, 2009, 10:19pm
2
I changed my form to POST and used this method…
CHtml::dropDownList('id', $select, $list, array('submit'=>'controller/action'));
Which works fine and uses jquery… i’d still like to know a way to use GET and submit the form value via friendly url?
Eliovir
(Eliovir)
October 29, 2009, 6:12am
3
I’m using this
<?= CHtml::form(); ?>
<?= CHtml::dropDownList('id', $select, $list, array('submit' => '')) ?>
<?= CHtml::endForm(); ?>
fibler
(Shaneog)
October 29, 2009, 2:13pm
4
Yeah that’s what im doing and it works for $_POST method. Is there a way to use dropdown with $_GET and maintain friendly URL’s?
So onchange of dropDownList your url is /controller/action/id/1 instead of /controller/action/?id=1
how to onchange function in dropdownlist
logos010
(Logos010)
November 13, 2010, 4:45am
6
Hi, i am new guy in Yii to, but i think somethings i can share with you:
If you want to give an onchange function in dropdownlist, you can following this code:
CHtml::dropDownList(
'select_box_name',
'select_value',
$data,
array(
'onchange' => 'alert(1)',
)
);
where $data is an array of listData
hope can help you
If you are planning to use onchange and wishes to use $_GET you need to set up you ajax to use method get instead of post.
ivica
(Ivica Nedeljkovic)
July 21, 2011, 9:55am
8
Have you setup urlManager in config file and in .htaccess to create friendly urls?
By the way, why you want to use SEO friendly URLs, on form submission pages, they will not be indexed by search engine anyway.
mdomba
(Maurizio Domba Cerin)
July 21, 2011, 10:11am
9
@Ivica note that you are posting on an old thread (last response from november 2010)… and in the Yii 1.0.x sub-forum (deprecated)…
traprajith
(Traprajith)
September 5, 2011, 5:39am
10
Help me mdomba …
i want to post the form onchange, what to do?
jacmoe
(Jacob Moena)
September 5, 2011, 7:03am
11
Start a new topic in the Yii 1.1 forum, please.
traprajith
(Traprajith)
September 5, 2011, 11:17am
12
got it myfriend,
<?php echo CHtml::dropDownList('id','select_value',$data,array('prompt'=>'Move To Folder','submit'=>array('user/inbox'))
);?>
or
<?php echo CHtml::dropDownList('id','select_value',$data,array('prompt'=>'Move To Folder','submit'=>'user/inbox')
);?>
*where data may CHtml::listData(…)
**user/inbox replace controller/action
richa
(Richa)
April 7, 2012, 5:52am
13
Hi Rajith,
I am using a similar thing as u mentioned above. I want to pass some values to the action. How do i do this?
Degger
(Degger)
April 9, 2012, 2:55pm
14
<?php echo CHtml::dropDownList('license_id', 'license',
License::items(),
array(
'empty'=>'Select License for this order',
'class'=>'span4',
'submit'=>array('order/addLicense', 'id'=>$model->orid), // id - will be sent as part of URL
'params'=>array('license_id'=>'js: $(this).val()'), // license_id will be send via POST and its value is selected value of dropDown
'csrf'=>true, // CSRF turned on in main config
));
?>
Helpfull links:
http://www.yiiframework.com/wiki/48/by-example-chtml/
http://www.yiiframework.com/wiki/24/