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