diff --git a/CHANGE.md b/CHANGE.md index e85c84c6..f3054a22 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,6 +1,6 @@ Version 2.6.0 ============= -**Date:** 19-Nov-2014 +**Date:** 20-Nov-2014 1. (enh #139): German translations updated. 2. (enh #140): French translations added. @@ -11,6 +11,7 @@ Version 2.6.0 7. (enh #145): Enhance style to enable floated header wrapper tables to autofit/expand inside panel. 8. (bug #146): Create Spanish translations. 9. (bug #147): ActionColumn dropdownButton label changes value only for 1st row. +9. (bug #148): Enhance EditableColumn to render unique ids for input widgets. #### BC Breaking Changes diff --git a/EditableColumn.php b/EditableColumn.php index e99e29e8..57363891 100644 --- a/EditableColumn.php +++ b/EditableColumn.php @@ -11,6 +11,7 @@ use Yii; use Closure; use yii\helpers\Html; +use yii\helpers\ArrayHelper; use yii\base\InvalidConfigException; use kartik\editable\Editable; use kartik\base\Config; @@ -54,6 +55,18 @@ public function init() Config::checkDependency('editable\Editable', 'yii2-editable', 'for GridView EditableColumn'); } + /** + * Set array value only if key not set + * @param array $array + * @param mixed $key + * @param mixed $value + */ + protected static function setVal(&$array, $key, $val) { + if (empty($array[$key])) { + $array[$key] = $val; + } + } + /** * Renders the data cell content. * @param mixed $model the data model @@ -84,7 +97,8 @@ public function renderDataCellContent($model, $key, $index) if ($this->attribute !== null) { $this->_editableOptions['model'] = $model; $this->_editableOptions['attribute'] = $this->attribute; - $this->_editableOptions['options']['id'] = $this->attribute . "-" . $index; + $type = ArrayHelper::getValue($this->_editableOptions, 'inputType', Editable::INPUT_TEXT); + static::setVal($this->_editableOptions['options'], 'id', $this->attribute . "-" . $index); } elseif (empty($this->_editableOptions['name']) && empty($this->_editableOptions['model']) || !empty($this->_editableOptions['model']) && empty($this->_editableOptions['attribute'])) { throw new InvalidConfigException("You must setup the 'attribute' for your EditableColumn OR set one of 'name' OR 'model' & 'attribute' in 'editableOptions' (Exception at index: '{$index}', key: '{$strKey}').");