Skip to content

Commit

Permalink
Merge pull request #2516 from zanemmm/master
Browse files Browse the repository at this point in the history
fix #2485 #1572 部分 Displayer 支持传递闭包参数
  • Loading branch information
z-song authored Sep 18, 2018
2 parents c70c1af + 9607ac2 commit 5385b41
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Grid/Displayers/Checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@
namespace Encore\Admin\Grid\Displayers;

use Encore\Admin\Admin;
use Illuminate\Contracts\Support\Arrayable;

class Checkbox extends AbstractDisplayer
{
public function display($options = [])
{
if ($options instanceof \Closure) {
$options = $options->call($this, $this->row);
}

$radios = '';
$name = $this->column->getName();

if (is_string($this->value)) {
$this->value = explode(',', $this->value);
}

if ($this->value instanceof Arrayable) {
$this->value = $this->value->toArray();
}

foreach ($options as $value => $label) {
$checked = in_array($value, $this->value) ? 'checked' : '';
$radios .= <<<EOT
Expand Down
4 changes: 4 additions & 0 deletions src/Grid/Displayers/Editable.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public function textarea()
*/
public function select($options = [])
{
if ($options instanceof \Closure) {
$options = $options->call($this, $this->row);
}

$source = [];

foreach ($options as $key => $value) {
Expand Down
4 changes: 4 additions & 0 deletions src/Grid/Displayers/Radio.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class Radio extends AbstractDisplayer
{
public function display($options = [])
{
if ($options instanceof \Closure) {
$options = $options->call($this, $this->row);
}

$radios = '';
$name = $this->column->getName();

Expand Down
4 changes: 4 additions & 0 deletions src/Grid/Displayers/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class Select extends AbstractDisplayer
{
public function display($options = [])
{
if ($options instanceof \Closure) {
$options = $options->call($this, $this->row);
}

$name = $this->column->getName();

$class = "grid-select-{$name}";
Expand Down

0 comments on commit 5385b41

Please sign in to comment.