Hello again people.
I have another (may be) silly question:
How can I trigger an action from a view in another way than a link or button?
Lets say: when a comboBox changes or when a radioButton is clicked.
Thanks in advance.
Hello again people.
I have another (may be) silly question:
How can I trigger an action from a view in another way than a link or button?
Lets say: when a comboBox changes or when a radioButton is clicked.
Thanks in advance.
You'll need to use some javascript code to do stuff like that, take a look at the documentation over at jQuery as Yii comes bundled with it. You should use Yii::app() -> clientScript -> registerScriptFile(path/to/Js); to render scripts into the header (tho you can just put them in your layout file if you wish), I have a base controller that loads the core stuff I need and then I can load others on demand as I need them.
From memory it maybe something like (don't quote me on it though lol):
$("#elmntWrapper").find("input:radio").click(function() { // do something });
Chris
Thanks to kradk3n for explaining.
CHtml provides a convenient option named submit that you can pass in the $htmlOptions parameter when you call CHtml::dropdownlist() or CHtml::checkBox.
For example, the category dropdownlist in the extensions page is using the following code:
<?php echo CHtml::dropDownList('cat',isset($_GET['cat'])?(int)$_GET['cat']:0, CHtml::listData($categories,'id','name'), array( 'empty'=>'All categories', 'submit'=>'')); ?>
Thanks for the answer. I have no time now to test these but I will do.