You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -116,21 +116,22 @@ other than '`active`', and a custom class '`form-option custom`' will be applied
116
116
117
117
#### Available methods
118
118
119
-
-`withLabel(string|callable $label)`: This method allows you to customize the label for each option. A string will be
120
-
used as the collection field from which the label will be generated, while a callable will be used to generate the
119
+
-`withLabel(string|Closure $label)`: This method allows you to customize the label for each option. A string will be
120
+
used as the collection field from which the label will be generated, while a Closure will be used to generate the
121
121
label.
122
-
-`withValue(string|callable $value)`: This method allows you to customize the value for each option. A string will be
123
-
used as the collection field from which the value will be generated, while a callable will be used to generate the
122
+
-`withValue(string|Closure $value)`: This method allows you to customize the value for each option. A string will be
123
+
used as the collection field from which the value will be generated, while a Closure will be used to generate the
124
124
value.
125
-
-`withSelected(mixed|callable $selected)`: This method allows you to customize the selected options. Can be
126
-
a `string`, `int`, an array of `string`/`int`, a `model` or a callable that returns a boolean value.
127
-
-`withDisabled(mixed|callable $disabled)`: This method allows you to customize the disabled options. Can be
128
-
a `string`, `int`, an array of `string`/`int`, a `model` or a callable that returns a boolean value.
129
-
-`withDataAttribute(string $attribute, mixed|callable $value)`: This method allows you to add a data attribute to each
130
-
option.
131
-
-`withClass(string $class)`: This method allows you to add a class to each option.
132
-
-`toSelectItems()`: This method converts the selectable collection to an array of selectable items. Useful for Ajax
133
-
responses or SPA.
125
+
-`withSelected(mixed|Closure $selected)`: This method allows you to customize the selected options. Can be
126
+
a `string`, `int`, an array of `string`/`int`, a `model` or a `Closure` that returns a `boolean` value.
127
+
-`withDisabled(mixed|Closure $disabled)`: This method allows you to customize the disabled options. Can be
128
+
a `string`, `int`, an array of `string`/`int`, a `model` or a `Closure` that returns a `boolean` value.
129
+
-`withDataAttribute(string|Closure $attribute, mixed|Closure $value)`: This method allows you to add a data attribute to each
130
+
option. The first parameter can be a `string` or a `Closure` that returns a `string` which will be attached as `data-{attribute}="{value}"` to the option. The second parameter can be any type convertable to a string or a `Closure` that returns a `string`.
131
+
-`withId(string|Closure $id)`: This method allows you to add an `id` attribute to each option. The value can be a `Closure` that returns a unique `string` for each option.
132
+
-`withClass(string|array|Closure $class)`: This method allows you to add a class to each option. The value can be a `string` or an `array` of `string` or a `Closure` that returns a `string`.
133
+
-`toSelectItems()`: This method converts the selectable collection to an `array` of selectable items. Useful for Ajax
134
+
responses or SPAs.
134
135
-`toSelectOptions()`: This method converts the selectable collection to an HTML select options string.
135
136
- Some of the methods from `Illuminate\Support\Collection` are also available including `groupBy()`.
136
137
@@ -142,14 +143,14 @@ You can work with collections of non-object arrays both flat and associative
0 commit comments