I am stumped and stuck! Seem like a common question though.
I have a Product Table and Product Group table. Product has GroupId element indicating BELONGS_TO relationship with Product Group table. Both have Models, Views and Controls.
Requirement: When I create product, I need to set which Group it belongs to. Example: product ‘iPhone’ belongs to ‘Smart Phones’ group.
So on Product Create form - I have group ID field. I tried dropdown and autocomplete options, both working well in getting the Group descriptions. However, dropdown field will not work since the group description list is too large. AutoComplete will not work since users have to know what to type. Hence my quest for an ajax dialog that will let users enter the criteria to filter on Group description.
This is what I have:
Product Create View:
–
$form=$this->beginWidget(‘CActiveForm’, array(
'id'=>'product-form',
'enableAjaxValidation'=>true,
–
<div class="row">
<?php echo $form->labelEx($model,‘group’); ?>
<?php echo $form->textField($model,‘group’); ?>
<?php echo $form->error($model,‘group’); ?>
</div>
–
<?php
echo CHtml::link(‘open dialog’, ‘#’, array(
‘onclick’=>’$("#mydialog").dialog(“open”); return false;’,
));
$this->beginWidget(‘zii.widgets.jui.CJuiDialog’, array(
'id'=>'mydialog',
'options'=>array(
'title'=>'Product Group',
'width' => 'auto',
'autoOpen'=>false,
),
));
$this->widget(‘zii.widgets.grid.CGridView’, array(
'dataProvider' => prodGroup::model()->search(),
'id' => 'CGridViewPgroup',
'filter'=>prodGroup::model(),
'columns' => array(
'id',
'name',
'status',
),
'htmlOptions' => array(
'style'=>'cursor: pointer;'
),
'selectionChanged'=>'js:function(id){ onSelectionChange(); }',
));
$this->endWidget('zii.widgets.jui.CJuiDialog');
?>
Dialog is pulling all the Group descriptions, however does not perform Filter operation. What am I doing wrong?