Skip to content

Commit b25699a

Browse files
committed
Merge pull request #68 from veksa/master
add check for closure in options
2 parents 7c21aec + 0642fca commit b25699a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,12 @@ or anonymous function which return array of items and has the following signatur
101101
function($data) {}
102102
```
103103

104-
**options** *array*: the HTML attributes for the input
104+
**options** *array*|*Closure*: the HTML attributes for the input, you can set it as array
105+
or an anonymous function with the following signature:
106+
107+
```php
108+
function($data) {}
109+
```
105110

106111
**headerOptions** *array*: the HTML attributes for the header cell
107112

src/components/BaseColumn.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,13 @@ private function normalize($name) {
228228
*/
229229
public function renderInput($name, $options)
230230
{
231-
$options = Arrayhelper::merge($this->options, $options);
231+
if ($this->options instanceof \Closure) {
232+
$optionsExt = call_user_func($this->options, $this->getModel());
233+
} else {
234+
$optionsExt = $this->options;
235+
}
236+
237+
$options = Arrayhelper::merge($optionsExt, $options);
232238
$method = 'render' . Inflector::camelize($this->type);
233239
$value = $this->prepareValue();
234240

0 commit comments

Comments
 (0)