0

I am not able to make the left list of multiselect widget in empty mode on load. It shows error when I set null value to the left list. This is my code:

  $this->widget('ext.widgets.multiselects.XMultiSelects', array(
                                    'leftTitle' => '',
                                    'leftName' => 'Certificate[selected][]',
                                    'leftList' => SpecificCertification::model()->findCertificate(),// here I need to make the list empty
                                    'rightTitle' => '',
                                    'rightName' => 'Certificate[all][]',
                                    'rightList' => SpecificCertification::model()->findCertificates(),
                                    'size' => 10,
                                ));

How can I make the left list empty ?

anu
  • 458
  • 2
  • 13
  • 36

1 Answers1

0

You need to open file widget XMultiSelects.php and modify it to fit your need

public function init()
    {
/* Comment out the below validation
        if(!isset($this->leftList))
        {
            throw new CHttpException(500,'"leftList" have to be set!');
        }
        if(!isset($this->rightList))
        {
            throw new CHttpException(500,'"rightList" have to be set!');
        }
*/
    }

Add validation for leftList and rightList such as below

if($this->leftList){
            foreach($this->leftList as $value=>$label)
            {
                echo "<option value=\"{$value}\">{$label}</option>\n";
            }
        }

and

if($this->rightList){
        foreach($this->rightList as $value=>$label)
            {
                echo "<option value=\"{$value}\">{$label}</option>\n";
            }
        }

After then, you can set null for them like what you did

Telvin Nguyen
  • 3,569
  • 4
  • 25
  • 39