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

Commit 6d71bdc

Browse files
committed
2 parents 8e568b4 + eb9e0d7 commit 6d71bdc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+710
-83
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
matrix:
1111
php: [8.0, 7.4]
1212
laravel: [8.*, 7.*]
13-
framework: [tailwind, tailwind-2, bootstrap-4]
13+
framework: [tailwind, tailwind-2, bootstrap-4, bootstrap-5]
1414
dependency-version: [prefer-lowest, prefer-stable]
1515
include:
1616
- laravel: 8.*

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22

33
All notable changes to `laravel-form-components` will be documented in this file
44

5+
## 3.0.0 - 2021-09-08
6+
7+
- Support for Bootstrap 5
8+
9+
## 2.5.4 - 2020-02-15
10+
11+
- Bugfix for old nested data
12+
13+
## 2.5.3 - 2020-02-11
14+
15+
- Bugfix for setting radio elements as checked/default
16+
17+
## 2.5.2 - 2020-01-04
18+
19+
- Generate ID by name *and* value (checkbox and radio elements only)
20+
21+
## 2.5.1 - 2020-12-22
22+
23+
- Use the `name` attribute to auto-generate an ID (if not set)
24+
525
## 2.5.0 - 2020-12-22
626

727
- Support for `BelongsToMany`, `MorphMany`, and `MorphToMany` relationships (select element)

README.md

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@
66
[![Total Downloads](https://img.shields.io/packagist/dt/protonemedia/laravel-form-components.svg?style=flat-square)](https://packagist.org/packages/protonemedia/laravel-form-components)
77
[![Buy us a tree](https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-lightgreen)](https://plant.treeware.earth/protonemedia/laravel-form-components)
88

9-
A set of Blade components to rapidly build forms with [Tailwind CSS v1](https://tailwindcss-custom-forms.netlify.app), [Tailwind CSS v2](https://tailwindcss-forms.vercel.app) and [Bootstrap 4](https://getbootstrap.com/docs/4.0/components/forms/). Supports validation, model binding, default values, translations, includes default vendor styling and fully customizable!
9+
A set of Blade components to rapidly build forms with [Tailwind CSS v1](https://tailwindcss-custom-forms.netlify.app), [Tailwind CSS v2](https://tailwindcss-forms.vercel.app), [Bootstrap 4](https://getbootstrap.com/docs/4.0/components/forms/) and [Bootstrap 5](https://getbootstrap.com/docs/5.1/forms/overview/). Supports validation, model binding, default values, translations, includes default vendor styling and fully customizable!
1010

11-
#### ... 👀 There's a Pro version of this package in development: check out [formcomponents.pro](https://formcomponents.pro)!
11+
## Launcher 🚀
1212

13-
### 📺 Want to see this package in action? Join the live stream on November 19 at 14:00 CET: [https://youtu.be/7eNZS4U7xyM](https://youtu.be/7eNZS4U7xyM)
13+
Hey! We've built a Docker-based deployment tool to launch apps and sites fully containerized. You can find all features and the roadmap on our [website](https://uselauncher.com), and we are on [Twitter](https://twitter.com/uselauncher) as well!
1414

1515
## Features
1616

17+
### 📺 Want to see this package in action? Join the live stream on November 19 at 14:00 CET: [https://youtu.be/7eNZS4U7xyM](https://youtu.be/7eNZS4U7xyM)
18+
1719
* Components for input, textarea, select, multi-select, checkbox and radio elements.
1820
* Support for Tailwind v1 with [Tailwind CSS Custom Forms](https://tailwindcss-custom-forms.netlify.app).
1921
* Support for Tailwind v2 with [Tailwind Forms](https://tailwindcss-forms.vercel.app/).
20-
* Support for [Bootstrap 4 Forms](https://getbootstrap.com/docs/4.0/components/forms/).
22+
* Support for [Bootstrap 4 Forms](https://getbootstrap.com/docs/4.6/components/forms/).
23+
* Support for [Bootstrap 5 Forms](https://getbootstrap.com/docs/5.1/forms/overview/).
2124
* Component logic independent from Blade views, the Tailwind and Bootstrap views use the same logic.
2225
* Bind a target to a form (or a set of elements) to provide default values (model binding).
2326
* Support for [Laravel Livewire](https://laravel-livewire.com) v2.
@@ -28,6 +31,8 @@ A set of Blade components to rapidly build forms with [Tailwind CSS v1](https://
2831
* Components classes and Blade views fully customizable.
2932
* Support for prefixing the components.
3033

34+
Looking for Inertia/Vue.js support? Check out [Form Components Pro](https://github.com/protonemedia/form-components-pro)
35+
3136
## Requirements
3237

3338
* PHP 7.4 + Laravel 7.0 and higher
@@ -75,7 +80,7 @@ If you're using Tailwind, make sure the right plugin ([v1](https://github.com/ta
7580
</x-form>
7681
```
7782

78-
<img src="https://github.com/pascalbaljetmedia/laravel-form-components/blob/master/quick-example-form.png?raw=true" width="450" />
83+
<img src="https://github.com/protonemedia/laravel-form-components/blob/master/quick-example-form.png?raw=true" width="450" alt="Quick example form"/>
7984

8085
## Preface
8186

@@ -130,7 +135,7 @@ You can also choose to use a `placeholder` instead of a label, and of course you
130135
<x-form-input type="email" name="current_email" placeholder="Current email address" />
131136
```
132137

133-
By default every element shows validation errors but you can hide them if you want.
138+
By default, every element shows validation errors, but you can hide them if you want.
134139

135140
```blade
136141
<x-form-textarea name="description" :show-errors="false" />
@@ -239,7 +244,7 @@ Normally you would use a `wire:model` attribute to bind a component property wit
239244
@endwire
240245
241246
<x-form-submit>Save Contact</x-form-submit>
242-
</form>
247+
</x-form>
243248
```
244249

245250
Additionally, you can pass an optional modifier to the `@wire` directive. This feature was added in v2.4.0. If you're upgrading from a previous version *and* you published the Blade views, you should republish them *or* update them manually.
@@ -249,7 +254,7 @@ Additionally, you can pass an optional modifier to the `@wire` directive. This f
249254
@wire('debounce.500ms')
250255
<x-form-input name="email" />
251256
@endwire
252-
</form>
257+
</x-form>
253258
```
254259

255260
### Select elements
@@ -321,8 +326,18 @@ You can group checkbox and radio elements on the same horizontal row by adding a
321326

322327
```blade
323328
<x-form-group name="notification_channel" label="How do you want to receive your notifications?" inline>
324-
<x-form-checkbox name="notification_channel" value="mail" label="Mail" />
325-
<x-form-checkbox name="notification_channel" value="slack" label="Slack" />
329+
<x-form-radio name="notification_channel" value="mail" label="Mail" />
330+
<x-form-radio name="notification_channel" value="slack" label="Slack" />
331+
</x-form-group>
332+
```
333+
334+
When you're not using target binding, you can use the `default` attribute to mark a radio element as checked:
335+
336+
337+
```blade
338+
<x-form-group name="notification_channel" label="How do you want to receive your notifications?">
339+
<x-form-radio name="notification_channel" value="mail" label="Mail" default />
340+
<x-form-radio name="notification_channel" value="slack" label="Slack" />
326341
</x-form-group>
327342
```
328343

@@ -396,29 +411,31 @@ By the default, the errors messages are positioned under the element. To show th
396411

397412
### Submit button
398413

399-
The label defaults to *Submit* but you can use the slot to provide your own content.
414+
The label defaults to *Submit*, but you can use the slot to provide your own content.
400415

401416
```blade
402417
<x-form-submit>
403418
<span class="text-green-500">Send</span>
404419
</x-form-submit>
405420
```
406421

407-
### Bootstrap 4
422+
### Bootstrap
408423

409-
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.
424+
You can switch to [Bootstrap 4](https://getbootstrap.com/docs/4.0/components/forms/) or [Bootstrap 5](https://getbootstrap.com/docs/5.0/forms/overview/) by updating the `framework` setting in the `form-components.php` configuration file.
410425

411426
```php
412427
return [
413-
'framework' => 'bootstrap-4',
428+
'framework' => 'bootstrap-5',
414429
];
415430
```
416431

417-
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.
432+
There is a little 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.
433+
434+
Bootstrap 5 changes a lot regarding forms. If you migrate from 4 to 5, make sure to read the migration logs about [forms](https://getbootstrap.com/docs/5.0/migration/#forms).
418435

419-
#### Input prepend and append
436+
#### Input group / prepend and append
420437

421-
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.
438+
In addition to the Tailwind features, with Bootstrap 4, there is also support for [input groups](https://getbootstrap.com/docs/4.6/components/forms/). Use the `prepend` and `append` slots to provide the contents.
422439

423440
```blade
424441
<x-form-input name="username" label="Username">
@@ -434,9 +451,28 @@ In addition to the Tailwind features, there is also support for [input groups](h
434451
</x-form-input>
435452
```
436453

454+
With Bootstrap 5, the [input groups](https://getbootstrap.com/docs/5.0/forms/input-group/) have been simplified. You can add as many items as you would like in any order you would like. Use the `form-input-group-text` component to add text or [checkboxes](https://getbootstrap.com/docs/5.0/forms/input-group/#checkboxes-and-radios).
455+
456+
```blade
457+
<x-form-input-group label="Profile" >
458+
<x-form-input name="name" placeholder="Name" id="name" />
459+
<x-form-input-group-text>@</x-form-input-group-text>
460+
<x-form-input name="nickname" placeholder="Nickname" id="nickname" />
461+
<x-form-submit />
462+
</x-form-input-group>
463+
```
464+
465+
#### Floating labels
466+
467+
As of Bootstrap 5, you can add [floating labels](https://getbootstrap.com/docs/5.0/forms/floating-labels/) by adding the `floating` attribute to inputs, selects (excluding `multiple`), and textareas.
468+
469+
```blade
470+
<x-form-input label="Floating Label" name="float_me" id="float_me" floating />
471+
```
472+
437473
#### Help text
438474

439-
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.
475+
You can add [block-level help text](https://getbootstrap.com/docs/4.6/components/forms/#help-text) to any element by using the `help` slot.
440476

441477
```blade
442478
<x-form-input name="username" label="Username">

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"tailwindcss",
88
"bootstrap",
99
"bootstrap4",
10+
"bootstrap5",
11+
"bootstrap-4",
12+
"bootstrap-5",
1013
"laravel",
1114
"form",
1215
"forms",

config/config.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
return [
66
'prefix' => '',
77

8-
/** tailwind | tailwind-2 | bootstrap-4 */
8+
/** tailwind | tailwind-2 | bootstrap-4 | bootstrap-5 */
99
'framework' => 'tailwind',
1010

1111
'components' => [
@@ -34,6 +34,16 @@
3434
'class' => Components\FormInput::class,
3535
],
3636

37+
'form-input-group' => [
38+
'view' => 'form-components::{framework}.form-input-group',
39+
'class' => Components\FormInputGroup::class,
40+
],
41+
42+
'form-input-group-text' => [
43+
'view' => 'form-components::{framework}.form-input-group-text',
44+
'class' => Components\FormInputGroupText::class,
45+
],
46+
3747
'form-label' => [
3848
'view' => 'form-components::{framework}.form-label',
3949
'class' => Components\FormLabel::class,
@@ -44,6 +54,11 @@
4454
'class' => Components\FormRadio::class,
4555
],
4656

57+
'form-range' => [
58+
'view' => 'form-components::{framework}.form-range',
59+
'class' => Components\FormRange::class,
60+
],
61+
4762
'form-select' => [
4863
'view' => 'form-components::{framework}.form-select',
4964
'class' => Components\FormSelect::class,

resources/views/bootstrap-4/form-checkbox.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
@if($isWired())
77
wire:model{!! $wireModifier() !!}="{{ $name }}"
8-
@else
9-
name="{{ $name }}"
108
@endif
119

10+
name="{{ $name }}"
11+
1212
@if($label && !$attributes->get('id'))
1313
id="{{ $id() }}"
1414
@endif

resources/views/bootstrap-4/form-input.blade.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
@if($isWired())
1717
wire:model{!! $wireModifier() !!}="{{ $name }}"
1818
@else
19-
name="{{ $name }}"
2019
value="{{ $value }}"
2120
@endif
2221

22+
name="{{ $name }}"
23+
2324
@if($label && !$attributes->get('id'))
2425
id="{{ $id() }}"
2526
@endif
@@ -32,11 +33,12 @@
3233
</div>
3334
</div>
3435
@endisset
36+
37+
@if($hasErrorAndShow($name))
38+
<x-form-errors :name="$name" />
39+
@endif
3540
</div>
3641

3742
{!! $help ?? null !!}
3843

39-
@if($hasErrorAndShow($name))
40-
<x-form-errors :name="$name" />
41-
@endif
4244
</div>

resources/views/bootstrap-4/form-radio.blade.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44

55
@if($isWired())
66
wire:model{!! $wireModifier() !!}="{{ $name }}"
7-
@else
8-
name="{{ $name }}"
97
@endif
108

9+
name="{{ $name }}"
1110
value="{{ $value }}"
1211

1312
@if($checked)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<div class="form-group">
2+
<x-form-label :label="$label" :for="$attributes->get('id') ?: $id()" />
3+
4+
<input
5+
{!! $attributes->merge(['class' => 'form-control-range' . ($hasError($name) ? ' is-invalid' : '')]) !!}
6+
7+
type="range"
8+
9+
@if($isWired())
10+
wire:model{!! $wireModifier() !!}="{{ $name }}"
11+
@else
12+
value="{{ $value }}"
13+
@endif
14+
15+
name="{{ $name }}"
16+
17+
@if($label && !$attributes->get('id'))
18+
id="{{ $id() }}"
19+
@endif
20+
/>
21+
22+
{!! $help ?? null !!}
23+
24+
@if($hasErrorAndShow($name))
25+
<x-form-errors :name="$name" />
26+
@endif
27+
</div>

resources/views/bootstrap-4/form-select.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
<select
55
@if($isWired())
66
wire:model{!! $wireModifier() !!}="{{ $name }}"
7-
@else
8-
name="{{ $name }}"
97
@endif
108

9+
name="{{ $name }}"
10+
1111
@if($multiple)
1212
multiple
1313
@endif

0 commit comments

Comments
 (0)