Skip to content

Commit 078360b

Browse files
author
Eugene Tupikov
committed
Customization of header cell
1 parent ee9c29d commit 078360b

File tree

4 files changed

+34
-10
lines changed

4 files changed

+34
-10
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ use unclead\widgets\MultipleInput;
8383
'format' => 'dd.mm.yyyy',
8484
'todayHighlight' => true
8585
]
86+
],
87+
'headerOptions' => [
88+
'style' => 'width: 250px;',
89+
'class' => 'day-css-class'
8690
]
8791
],
8892
[
@@ -113,7 +117,8 @@ Widget support the following options that are additionally recognized over and a
113117
- `value` *Closure*: you can set it to an anonymous function with the following signature: ```function($data) {}```
114118
- `defaultValue` *string*: default value of input,
115119
- `items` *array*: the items for input with type dropDownList, listBox, checkboxList, radioList
116-
- `options` *array*: the HTML options of input
120+
- `options` *array*: the HTML attributes for the input
121+
- `headerOptions` *array*: the HTML attributes for the header cell
117122

118123
### Input types
119124

examples/views/example.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
'format' => 'dd.mm.yyyy',
5959
'todayHighlight' => true
6060
]
61+
],
62+
'headerOptions' => [
63+
'style' => 'width: 250px;',
64+
'class' => 'day-css-class'
6165
]
6266
],
6367
[

src/MultipleInput.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,7 @@ private function renderHeader()
150150
$cells = [];
151151
foreach ($this->columns as $column) {
152152
/* @var $column MultipleInputColumn */
153-
if ($column->isHiddenInput() || empty($column->title)) {
154-
continue;
155-
}
156-
$cells[] = Html::tag('th', $column->title, [
157-
'class' => 'list-cell__' . $column->name
158-
]);
153+
$cells[] = $column->renderHeaderCell();
159154
}
160155
if (is_null($this->limit) || $this->limit > 1) {
161156
$cells[] = Html::tag('th', '', [

src/MultipleInputColumn.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class MultipleInputColumn extends Object
3030
const TYPE_STATIC = 'static';
3131

3232
/**
33-
* @var string
33+
* @var string input name
3434
*/
3535
public $name;
3636

@@ -40,7 +40,7 @@ class MultipleInputColumn extends Object
4040
public $title;
4141

4242
/**
43-
* @var string
43+
* @var string input type
4444
*/
4545
public $type;
4646

@@ -50,7 +50,7 @@ class MultipleInputColumn extends Object
5050
public $value;
5151

5252
/**
53-
* @var mixed
53+
* @var mixed default value for input
5454
*/
5555
public $defaultValue = '';
5656

@@ -64,6 +64,11 @@ class MultipleInputColumn extends Object
6464
*/
6565
public $options;
6666

67+
/**
68+
* @var array the HTML attributes for the header cell tag.
69+
*/
70+
public $headerOptions = [];
71+
6772
/**
6873
* @var MultipleInput
6974
*/
@@ -103,6 +108,21 @@ public function hasHeader()
103108
return !empty($this->title);
104109
}
105110

111+
/**
112+
* Renders the header cell.
113+
* @return null|string
114+
*/
115+
public function renderHeaderCell()
116+
{
117+
if ($this->isHiddenInput()) {
118+
return null;
119+
}
120+
121+
$options = $this->headerOptions;
122+
Html::addCssClass($options, 'list-cell__' . $this->name);
123+
return Html::tag('th', $this->title, $options);
124+
}
125+
106126
/**
107127
* Prepares the value of column.
108128
*

0 commit comments

Comments
 (0)