All notable changes to `laravel-form-components` will be documented in this file
4
4
5
+
## 3.5.0 - 2022-01-05
6
+
7
+
- Added `default_wire` configuration
8
+
- Fix for overriding `wire:model` attribute
9
+
5
10
## 3.4.0 - 2022-01-04
6
11
7
12
- Added `tailwind-forms-simple` views
Original file line number
Diff line number
Diff line change
@@ -266,7 +266,7 @@ class ContactForm extends Component
266
266
}
267
267
```
268
268
269
-
Normally you would use a `wire:model` attribute to bind a component property with a form element. By using the `@wire` directive, this package will automatically use the `wire:model` attribute instead of the `name` attribute.
269
+
Normally you would use a `wire:model` attribute to bind a component property with a form element. By using the `@wire` directive, this package will automatically add the `wire:model` attribute.
270
270
271
271
```blade
272
272
<x-form wire:submit.prevent="submit">
@@ -289,6 +289,8 @@ Additionally, you can pass an optional modifier to the `@wire` directive. This f
289
289
</x-form>
290
290
```
291
291
292
+
It's also possible to use the `wire:model` attribute by default. You may set the `default_wire` configuration setting to `true` or a modifier like `debounce.500ms`. This way, you don't need the `@wire` and `@endwire` directives in your views. You may still override the default setting by manually adding the `wire:model` attribute to a form element.
293
+
292
294
### Select elements
293
295
294
296
Besides the `name` attribute, the `select` element has a required `options` attribute, which should be a simple *key-value* array.
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,9 @@
10
10
11
11
'use_eloquent_date_casting' => false,
12
12
13
+
/** bool | string */
14
+
'default_wire' => false,
15
+
13
16
'components' => [
14
17
'form' => [
15
18
'view' => 'form-components::{framework}.form',
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,10 @@ public function render()
36
36
*/
37
37
publicfunctionisWired(): bool
38
38
{
39
+
if ($this->attributes && count($this->attributes->whereStartsWith('wire:model')->getIterator())) {
40
+
returnfalse;
41
+
}
42
+
39
43
returnapp(FormDataBinder::class)->isWired();
40
44
}
41
45
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,11 @@ class FormDataBinder
16
16
*/
17
17
private$wire = false;
18
18
19
+
/**
20
+
* Whether the default wire has been verified once.
0 commit comments