Skip to content
This repository was archived by the owner on Jan 2, 2024. It is now read-only.

Commit 884580a

Browse files
committed
Update README.md
1 parent 160e08c commit 884580a

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ You can even mix targets!
136136
</x-form>
137137
```
138138

139-
## Select
139+
### Select elements
140140

141141
Besides the `name` attribute, the `select` element has a required `options` attribute, which should be a simple *key-value* array.
142142

@@ -157,6 +157,45 @@ If you want a select where multiple options can be selected, add the `multiple`
157157
<x-form-select name="country_code" :options="$countries" multiple :default="['be', 'nl']" />
158158
```
159159

160+
### Checkbox elements
161+
162+
Checkboxes have a default value of `1`, but you can customize it as well.
163+
164+
```blade
165+
<x-form-checkbox name="subscribe_to_newsletter" label="Subscribe to newsletter" />
166+
```
167+
168+
If you have a fieldset of multiple checkboxes, you can group them together with the `form-group` component. This component has an optional `label` attribute and you can set the `name` as well. This is a great way to handle the validation of arrays. If you disable the errors on the individual checkboxes, it will one show the validation errors once. The `form-group` component has a `show-errors` attribute that defaults to `true`.
169+
170+
```blade
171+
<x-form-group name="interests" label="Pick one or more interests">
172+
<x-form-checkbox name="interests[]" :show-errors="false" value="laravel" label="Laravel" />
173+
<x-form-checkbox name="interests[]" :show-errors="false" value="tailwindcss" label="Tailwind CSS" />
174+
</x-form-group>
175+
```
176+
177+
### Radio elements
178+
179+
Radio elements behave exactly the same as checkboxes, except the `show-errors` attribute defaults to `false` as you almost always want to wrap multiple radio elements in a `form-group`.
180+
181+
*todo*
182+
183+
### Old data
184+
185+
*todo*
186+
187+
### Handling translations
188+
189+
*todo*
190+
191+
### Customize the blade views
192+
193+
*todo*
194+
195+
### Customize the components
196+
197+
*todo*
198+
160199
### Testing
161200

162201
``` bash

0 commit comments

Comments
 (0)