Yii 1.1: mcdropdown

Multilevel Select Replacement Extension using mcDropdown

you use it on a form that requires the user to select from a multilevel field (like a category); check the image attached to see a preview.

it shows as follows; and returns a hidden field with the value named as it should on the form.



...requirements of using this extension (e.g. Yii 1.1 or above)...


                        'data' => categorias::getData(),

the form attribute is a CActiveForm for easy form implementation; the data has to be an array of data as follows:

  "text"=>"Whatever Text"
  "id" =>22
   ... and so on

I use this function to get it from a table that has a parent field at a model.. you may adapt it as needed.

public function getData($cnd=" is NULL") {
                        $data = array();                        
             foreach(categorias::model()->findAll('parent'.$cnd) as $model) {
                                $row['text'] = $model->descripcion_en;
                                $row['id'] = $model->catid;
                                $row['children'] = $this->getData(' ='.$model->catid);                  
                                $data[] = $row;
             return $data;

Total 4 comments

#17479 report it
zop at 2014/06/19 06:32am
Don't Work

For me don't work, i had a wite textfield without any possibility of selection, hao do I use it in the form??? I have put it like this example code but don't work, can anyone help me please?

<?php $form=$this->beginWidget('CActiveForm', array( 'id'=>'category-form', 'enableAjaxValidation'=>true, )); ?>

Fields with * are required.

<?php echo $form->errorSummary($model); ?> <? $this->widget('application.extensions.mcdropdown.McDropdown',array( 'model'=>$model, 'attribute'=>'division', 'form'=>$form, 'data' => Categorias::getData(), )); ?>
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
<?php $this->endWidget(); ?>
#15778 report it
dannythebestguy at 2013/12/16 01:18pm
Yii 2.0 version

Will we have a Yii 2.0 version for this plugin.


#5812 report it
volkmar at 2011/11/15 03:17pm
Please update the javascript of the mcDropdown jQuery Plugin

Hint: v1.3.1 (2011-07-26) Fixed support for jQuery v1.6.2

#2695 report it
xalakox at 2011/01/30 02:34am
Update Version

It had weird behavior, the value of the field was not posted because of the mcDropdown plugin; so it now creates a hidden field and poses another field to show the drop-down; the hidden fields gets posted.

Leave a comment

Please to leave your comment.

Create extension