digitick / yii-combobox

Yii extension : A jQuery combobox, based on autocomplete
http://www.yiiframework.com/extension/combobox/
6 stars 14 forks source link

not accepting null values #6

Open maxxer opened 10 years ago

maxxer commented 10 years ago

If the widget is loaded with empty "options" (i.e. when they're loaded dinamically) throws an error.

This patch fixes:

commit 721e136edfc5122be0b1d10a5f8251dd2ea001ad
Author: Lorenzo Milesi <maxxer@yetopen.it>
Date:   Wed Nov 13 23:48:19 2013 +0100

    CJuiComboBox: bugfix per opzione vuota

diff --git a/ssl/management_site/protected/extensions/combobox/EJuiComboBox.php b/ssl/management_site/protected/extensions/combobox/EJuiComboBox.php
index ebabf05..26b6224 100644
--- a/ssl/management_site/protected/extensions/combobox/EJuiComboBox.php
+++ b/ssl/management_site/protected/extensions/combobox/EJuiComboBox.php
@@ -89,7 +89,11 @@ class EJuiComboBox extends CJuiInputWidget
        else
            echo CHtml::dropDownList($name, $this->value, $data);

-       echo CHtml::textField(null,($this->hasModel()?$data[CHtml::resolveValue($this->model,$this->attribute)]:$data[$this->value]),  CMap::mergeArray(array('id'=>$id.'_combobox'),$this->htmlOptions));
+                if (!empty($data))
+                    $value = $this->hasModel()?$data[CHtml::resolveValue($this->model,$this->attribute)]:$data[$this->value];
+                else 
+                    $value = "";
+       echo CHtml::textField(null,$value, CMap::mergeArray(array('id'=>$id.'_combobox'),$this->htmlOptions));
        $this->options = array_merge($this->defaultOptions, $this->options);

        $options = CJavaScript::encode($this->options);