-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHiddenInputColumn.php
More file actions
45 lines (36 loc) · 1.1 KB
/
Copy pathHiddenInputColumn.php
File metadata and controls
45 lines (36 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace dacduong\inlinegrid;
use yii\helpers\Html;
class HiddenInputColumn extends DataColumn
{
public $name = 'ddhiddeninput';
public $cssClass = 'dd-hidden';
public $controlOptions = [];
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (!array_key_exists('class', $this->controlOptions)) {
$this->controlOptions['class'] = 'value-'.$this->attribute;
} else {
$this->controlOptions['class'] .= ' value-'.$this->attribute;
}
}
/**
* @inheritdoc
*/
protected function renderDataCellContent($model, $key, $index)
{
if ($this->attribute !== null) {
$this->name = Html::getInputName($model, "[{$index}]{$this->attribute}");
}
if ($this->content === null) {
$value = $this->getDataCellValue($model, $key, $index);
return Html::hiddenInput($this->name, $value, $this->controlOptions);
} else {
return parent::renderDataCellContent($model, $key, $index);
}
}
}