@@ 56-68 (lines=13) @@ | ||
53 | * |
|
54 | * @return static |
|
55 | */ |
|
56 | public function options($options) |
|
57 | { |
|
58 | return $this->addChildren($options, function ($text, $value) { |
|
59 | if (is_array($text)) { |
|
60 | return $this->optgroup($value, $text); |
|
61 | } |
|
62 | ||
63 | return Option::create() |
|
64 | ->value($value) |
|
65 | ->text($text) |
|
66 | ->selectedIf($value === $this->value); |
|
67 | }); |
|
68 | } |
|
69 | ||
70 | /** |
|
71 | * @param string $label |
|
@@ 76-88 (lines=13) @@ | ||
73 | * |
|
74 | * @return static |
|
75 | */ |
|
76 | public function optgroup($label, $options) |
|
77 | { |
|
78 | return Optgroup::create() |
|
79 | ->label($label) |
|
80 | ->addChildren($options, function ($text, $value) { |
|
81 | return Option::create() |
|
82 | ->value($value) |
|
83 | ->text($text) |
|
84 | ->selectedIf($value === $this->value); |
|
85 | }); |
|
86 | ||
87 | return $this->addChild($optgroup); |
|
88 | } |
|
89 | ||
90 | /** |
|
91 | * @param string|null $text |