In the List view i added radio button list for filter the result. How pass the radio button value to the controller action onchange? Radio button list code like this
<?php echo CHtml::radioButtonList('type','',array(
'1'=>'Personal',
'2'=>'Organization'),array('id'=>'type'),array( 'separator' => "<br/>",'style'=>'display:inline')
);
?>
On change want to pass the value to controller action and refresh the result?
satan666
(Nirmal9847)
March 18, 2013, 6:29am
2
In the List view i added radio button list for filter the result. How pass the radio button value to the controller action onchange? Radio button list code like this
<?php echo CHtml::radioButtonList('type','',array(
'1'=>'Personal',
'2'=>'Organization'),array('id'=>'type'),array( 'separator' => "<br/>",'style'=>'display:inline')
);
?>
On change want to pass the value to controller action and refresh the result?
you pass a value to controller then you are looking for an ajax call…but what exactly is your purpose?
The list view used as a search result.
Controller
public function actionSearch()
{
$key=$_GET['Text'];
$criteria = new CDbCriteria();
$criteria->addSearchCondition('username',$key,true,"OR");
$criteria->select = "`username`,`country`";
$data=new CActiveDataProvider('User',
array('criteria'=>$criteria,'pagination'=>array('pageSize'=>5),
));
$this->render('search', array(
'ModelInstance' => User::model()->findAll($criteria),
'dataProvider'=>$data,
));
}
search.php
<?php
//THE WIDGET WITH ID AND DYNAMICALLY MADE SORTABLEATTRIBUTES PROPERTY
$this->widget('zii.widgets.CListView', array(
'id'=>'user-list',
'dataProvider'=>$dataProvider,
'itemView'=>'results',
'template' => '{sorter}{items}{pager}',
));
?>
<?php echo CHtml::radioButtonList('type','',array(
'1'=>'Personal',
'2'=>'Organization'),array('id'=>'type'),array( 'separator' => "<br/>",'style'=>'display:inline')
);
?>
result.php
<?php echo $data->username."<br>"; ?>
<?php echo $data->country; ?>
The user model fields are id, name , country, type, The search result shows the name and country. Now want to filter the results based on the radio button onchange (personal/organisation).
Thanks.
gusnips
(Gustavo)
March 18, 2013, 1:38pm
5
add this script to reload on change
//view
Yii::app()->clientScript->registerScript('on-change-type','
$("#type").on("change", function(){
window.location = "' . Yii::app()->createUrl("controller/action"). '?type=" + $(this).val();
});
');
//action
$type = $_GET['type'];
//do something to filter