Sorry I did not say it’s not working. What am saying is that am trying to use it in my that prevously this code
echo $form->checkBoxList($model, 'featureIds', $model->getFeaturesOptions());
Note that am passing it in partial render _form and my getFeaturesOptions() method is here.
/*
* Get the features list
*/
public function getFeaturesOptions()
{
return CHtml::listData(AutoFeatures::model()->findAll(), 'id', 'features');
}
Here is the forum am following to solve this issue with many-to-many relationship.
http://www.yiiframework.com/forum/index.php?/topic/20320-working-with-a-checkbox-list/
I have three table autos, features, and auto-features the connecting table for the two where an auto can have many features and many features can belong to many autos.
This the error am getting Undefined index: featureIds
This is what I have as part of the extension. It clearly pulls the value for the getFeatureOptions fine but how can I pass in the featureIds as my previous code used to work fine. Again if you look in the forum I have given the link will give a clear view of what am talking about.
<?php
$this->widget('application.extensions.EchMultiselect.EchMultiselect', array(
//the data model associated with this widget:
'model' => $model,
// the attribute associated with drop down list of this widget:
//'dropDownAttribute' => 'color',
// data for generating the options of the drop down list:
'data' => $model->getFeaturesOptions(),
// the name of the drop down list (this must be set if 'model' and 'dropDownAttribute' are not set):
'name' => 'model_color',
// the selected input value(s) (used only if 'model' and 'dropDownAttribute' are not set)
'value' => array($model, 'featureIds'),
// additional HTML attributes for the drop down list:
'dropDownHtmlOptions'=> array(
'style'=>'width:240px;',
),
// options for the jQuery UI MultiSelect Widget
// (see the project page for available options):
'options' => array(
'header'=>true,
'height'=>175,
'minWidth'=>225,
'checkAllText'=>Yii::t('application','Check all'),
'uncheckAllText'=>Yii::t('application','Uncheck all'),
'noneSelectedText'=>Yii::t('application','Select an Option'),
'selectedText'=>Yii::t('application','# selected'),
'selectedList'=>false,
'show'=>'',
'hide'=>'',
'autoOpen'=>false,
'multiple'=>true,
'classes'=>'',
'position'=>array(),
// set this to true, if you want to use the Filter Widget
'filter'=>false,
),
// options for the jQuery UI MultiSelect Filter Widget
'filterOptions'=> array(
'label' => Yii::t('application','Filter:'),
'width'=>100,
'placeholder'=>Yii::t('application','Enter keywords'),
'autoReset'=>false,
),
));
?>
<?php //echo $form->checkBoxList($model, 'featureIds', $model->getFeaturesOptions());
?>
</div>
</div>
<div class="clear"></div>
</div>
<div class="rowElem">
<div class="fleft">
<div class="row">
<?php echo $form->labelEx($model,'description'); ?>
<?php echo $form->textArea($model,'description',array('rows'=>8, 'cols'=>35)); ?>
<?php echo $form->error($model,'description'); ?>
</div>
</div>
<div class="fleft marg_left">
<div class="row">
</div>
</div>
<div class="fleft marg_left">
<div class="row">
<?php echo $form->labelEx($model,'vin'); ?>
<?php echo $form->textField($model,'vin',array('size'=>17,'maxlength'=>17)); ?>
<?php echo $form->error($model,'vin'); ?>
</div>
</div>
<div class="clear"></div>
</div>
<div class="rowElem">
<div class="fleft">
<div class="row">
<?php echo $form->labelEx($model,'tags'); ?>
<?php $this->widget('CAutoComplete', array(
'model'=>$model,
'attribute'=>'tags',
'url'=>array('suggestTags'),
'multiple'=>true,
'htmlOptions'=>array('size'=>25),
)); ?>
<p class="hint">Please separate different tags with commas.</p>
<?php echo $form->error($model,'tags'); ?>
</div>
</div>
<div class="fleft marg_left">
<div class="row">
</div>
</div>
<div class="fleft marg_left">
<div class="row">
Maximum of 8 images allowed
<?php
$this->widget('CMultiFileUpload', array(
'name' => 'images[]',
'accept' => 'jpeg|jpg|gif|png', // useful for verifying files
'duplicate' => 'Duplicate file!', // useful, i think
'denied' => 'Invalid file type', // useful, i think
'max' => '8',
'remove' => 'Delete'
));
?>