Skip to content

Commit

Permalink
Fix #149: Correct validation for EditableColumn ActiveForm attribs
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Nov 22, 2014
1 parent 9eddf20 commit 1989498
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions EditableColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,6 @@ 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
Expand Down Expand Up @@ -96,9 +84,8 @@ public function renderDataCellContent($model, $key, $index)
}
if ($this->attribute !== null) {
$this->_editableOptions['model'] = $model;
$this->_editableOptions['attribute'] = $this->attribute;
$this->_editableOptions['attribute'] = "[{$index}]{$this->attribute}";
$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}').");
Expand Down

0 comments on commit 1989498

Please sign in to comment.