I am using the XMultiSelects widget. I have a list of sites for the user to review and approve.
I would like to put a filter on the page above the list to allow the user to filter the list by category.
I can add a dropdownlist object, but not sure how to trigger the update.
My _searchCat.php file
<div class="wide form">
<?php $form = $this->beginWidget('CActiveForm', array(
'action' => Yii::app()->createUrl($this->route),
'method' => 'get',
)); ?>
<div class="row">
<?php echo $form->label($model, 'campaign_id'); ?>
<?php echo $form->dropDownList($model, 'campaign_id', CHtml::listData(Campaign::model()->findAll('partner_id ='.$partner_id),'id', 'title'), array( 'prompt'=>'Select Campaign')); ?>
</div>
<div class="row">
<?php echo $form->label($model, 'category_id'); ?>
<?php echo $form->dropDownList($model, 'category_id', CHtml::listData(ContentCategory::model()->findAll(),'id', 'category'), array('multiple'=>'multiple', 'prompt'=>'Pick Any', 'unselectValue'=>NULL )); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton(Yii::t('app', 'Search')); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- search-form -->
My approve.php file
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$.fn.yiiGridView.update('ApproveSites', {
data: $(this).serialize()
});
return false;
});
");
?>
<?php echo CHtml::link(Yii::t('app', 'Category Search'),'#',array('class'=>'search-button')); ?>
<div class="search-form" style="display: none">
<?php $this->renderPartial('_searchCats',array(
'model'=>PartnerSite::model()->find($model->id), 'partner_id'=>$model->id,
)); ?>
</div><!-- search-form -->
<div class="form">
<br />
<?php echo $form = CHtml::beginForm($this->createUrl('ApproveSites')); ?>
<?php if ($mode == 'Blacklist')
$this->widget('ext.widgets.multiselects.XMultiSelects',array(
'leftTitle'=>$lefthead,
'leftName'=>'PartnerSite[needreview][]',
'leftList'=>PartnerSite::model()->findSites($model->id,'NeedReview'),
'rightTitle'=>$righthead,
'rightName'=>'PartnerSite[approved][]',
'rightList'=>PartnerSite::model()->findSites($model->id,'Approved'),
'size'=>20,
'width'=>'300px',
));
....
My model had a method defined
public function findSites($partner_id, $approve, $cat)
{
$criteria=array(
'select'=>' partner_id, website_id, approve ',
'condition'=>'partner_id='.$partner_id.' and approve ='."'$approve'",
'order'=>'site_url',
);
$partnerSites = PartnerSite::model()->with('website')->findAll($criteria);
return CHtml::listData($partnerSites,'id','website.site_url');
}
How do I get this to reload the list in the widgets?
Thanks for any help or ideas!