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
{{ message }}
This repository was archived by the owner on Jan 2, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+68-15Lines changed: 68 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,15 +10,15 @@ A set of Blade components to build forms with [Tailwind CSS Custom Forms](https:
10
10
11
11
## Features
12
12
13
-
* Components for input, textarea, select, multi-select, checkbox and radio elements
14
-
* Support for [Tailwind CSS Custom Forms](https://tailwindcss-custom-forms.netlify.app)
15
-
* Bind a target to a form (or a set of elements) to provide default values
16
-
* Support for Spatie's [laravel-translatable](https://github.com/spatie/laravel-translatable)
17
-
* Re-populate forms with [old input](https://laravel.com/docs/master/requests#old-input)
18
-
* Validation errors
19
-
* Components classes and Blade views fully customizable
20
-
* Support for prefixing the components
21
-
*Prepared for other CSS frameworks as well (in a future release)
13
+
* Components for input, textarea, select, multi-select, checkbox and radio elements.
14
+
* Support for [Tailwind CSS Custom Forms](https://tailwindcss-custom-forms.netlify.app) and [Bootstrap 4 Forms](https://getbootstrap.com/docs/4.0/components/forms/).
15
+
* Bind a target to a form (or a set of elements) to provide default values.
16
+
* Support for Spatie's [laravel-translatable](https://github.com/spatie/laravel-translatable).
17
+
* Re-populate forms with [old input](https://laravel.com/docs/master/requests#old-input).
18
+
* Validation errors.
19
+
* Components classes and Blade views fully customizable.
20
+
* Support for prefixing the components.
21
+
*Component logic independent from Blade views, the Tailwind and Bootstrap views use the same logic.
22
22
23
23
## Requirements
24
24
@@ -98,15 +98,15 @@ By default every element shows validation errors but you can hide them if you wa
You can use the `default` attribute to specify the default value of the element.
104
104
105
105
```blade
106
106
<x-form-textarea name="motivation" default="I want to use this package because..." />
107
107
```
108
108
109
-
### Binding a target
109
+
####Binding a target
110
110
111
111
Instead of setting a default value, you can also pass in a target, like an Eloquent model. Now the component will get the value from the target by the `name`.
112
112
@@ -116,7 +116,7 @@ Instead of setting a default value, you can also pass in a target, like an Eloqu
116
116
117
117
In the example above, where `$video` is an Eloquent model, the default value will be `$video->description`.
118
118
119
-
### Binding a target to multiple elements
119
+
####Binding a target to multiple elements
120
120
121
121
You can also bind a target by using the `@bind` directive. This will bind the target to all elements until the `@endbind` directive.
122
122
@@ -145,7 +145,7 @@ You can even mix targets!
145
145
</x-form>
146
146
```
147
147
148
-
### Override or remove a binding
148
+
####Override or remove a binding
149
149
150
150
You can override the `@bind` directive by passing a target directly to the element using the `:bind` attribute. If you want to remove a binding for a specific element, pass in `false`.
You can find the Blade views in the `resources/views/vendor/form-components` folder. Optionally, in the `form-components.php` configuration file, you can change the location of the Blade view *per* component.
242
242
243
-
###Customize the components
243
+
#### Component logic
244
244
245
245
You can bind your own component classes to any of the elements. In the `form-components.php` configuration file, you can change the class *per* component. As the logic for the components is quite complex, it is strongly recommended to duplicate the default component as a starting point and start editing. You'll find the default component classes in the `vendor/protonemedia/laravel-form-components/src/Components` folder.
246
246
@@ -249,7 +249,6 @@ You can bind your own component classes to any of the elements. In the `form-com
249
249
You can define a prefix in the `form-components.php` configuration file.
250
250
251
251
```php
252
-
253
252
return [
254
253
'prefix' => 'tailwind',
255
254
];
@@ -277,6 +276,60 @@ By the default, the errors messages are positioned under the element. To show th
277
276
</x-form>
278
277
```
279
278
279
+
### Submit button
280
+
281
+
The label defaults to *Submit* but you can use the slot to provide your own content.
282
+
283
+
```blade
284
+
<x-form-submit>
285
+
<span class="text-green-500">Send</span>
286
+
</x-form-submit>
287
+
```
288
+
289
+
### Bootstrap 4
290
+
291
+
You can switch to [Bootstrap 4](https://getbootstrap.com/docs/4.0/components/forms/) by updating the `framework` setting in the `form-components.php` configuration file.
292
+
293
+
```php
294
+
return [
295
+
'framework' => 'bootstrap-4',
296
+
];
297
+
```
298
+
299
+
There is a little bit of styling added to the `form.blade.php` view to add support for inline form groups. If you want to change it or remove it, [publish the assets](#customize-the-blade-views) and update the view file.
300
+
301
+
#### Input prepend and append
302
+
303
+
In addition to the Tailwind features, there is also support for [input groups](https://getbootstrap.com/docs/4.1/components/forms/#auto-sizing). Use the `prepend` and `append` slots to provide the contents.
304
+
305
+
```blade
306
+
<x-form-input name="username" label="Username">
307
+
@slot('prepend')
308
+
<span>@</span>
309
+
@endslot
310
+
</x-form-input>
311
+
312
+
<x-form-input name="subdomain" label="Subdomain">
313
+
@slot('append')
314
+
<span>.protone.media</span>
315
+
@endslot
316
+
</x-form-input>
317
+
```
318
+
319
+
#### Help text
320
+
321
+
You can add [block-level help text](https://getbootstrap.com/docs/4.1/components/forms/#help-text) to any element by using the `help` slot.
0 commit comments