Closed aerni closed 4 months ago
@aerni What is the status on this? The latest tagged release is 8.1.0 which isn't compatible with LiveWire 3 yet.
I'm working on the finishing touches. This version is a complete refactor. The biggest work now is the upgrade guide.
@aerni Nice! Can I already test it out? When do you expect to tag 3.0?
Sure, you can check out this branch to take it for a spin. You'll run into more or less breaking changes depending on your setup. I don't have an ETA.
@ceesvanegmond I'm almost ready to tag a release. Are you planning to update any time soon? If yes, are you willing to test drive this PR before I tag a release? I added an upgrade guide at the top that should contain all the major road blocks.
@aerni I updated our application to latest dev-main en everything seem to be allright! Very Nice!
@ceesvanegmond The main
branch is behind a lot and doesn't cover any of the breaking changes. You should check out major-refactor
instead.
Hello, do you plan to support Statamic V5 in this release?
Yes, that's the plan! 😄
This PR features a major refactor of the codebase with many improvements and new features. There are some breaking changes that require your attention when upgrading.
What's new
FieldSynth
synthesizerBreaking changes
@formSections
,@formHoneypot
,@formSubmit
,@formErrors
and@formSuccess
blade directives with a global@formView
directive.hydratedFields
,submittingForm
,createdSubmission
, andsubmittedForm
hooks.submissionCreated
event.$HANDLE
,$VIEW
and$THEME
component properties.showLabel
field property.Upgrade Guide
This upgrade guide takes you through the breaking changes of this PR. If you made major customizations to the underlying Livewire form component, you might run into more breaking changes, as this PR features a complete rewrite of the codebase. Feel free to reach out if you encounter any breaking changes that are not listed below.
Themes and views
The theme directory and views have been restructured and optimized. The changes include Alpine for field conditions and general improvements of field views. I recommend you publish a temporary migration theme and view using the setup command, and adapt your existing views accordingly.
Renamed views
checkbox.blade.php
view has been renamed tocheckboxes.blade.php
input.blade.php
view has been renamed todefault.blade.php
file.blade.php
view has been renamed toassets.blade.php
Blade directives
The
@formSections
,@formHoneypot
,@formSubmit
,@formErrors
and@formSuccess
blade directives have been removed in favor of a new@formView
blade directive.label
propertyThe
label
property has been renamed todisplay
for consistency with Statamic's naming scheme. You should update your views accordingly.showLabel
propertyThe
showLabel
property has been removed. This change is reflected in the updated views.Form components
If you've got a custom form component, you should apply the following changes.
Extending component
The component namespace has changed. Update accordingly:
Component properties
The static component properties
$HANDLE
,$VIEW
, and$THEME
have been removed. You should mount the public properties instead:Hooks
hydratedFields
The
hydratedFields
hook has been removed. There are a couple of alternatives you can use instead.mountedFields
The
mountedFields
hook is called when the component is mounted. It is more efficient from a performance point of view as it is only called once. This hook is what you should be using most of the time.hydrateFields
The
hydrateFields
hook works similar to the deprecatedhydratedFields
hook. It is called every time the component is hydrated. This hook allows for dynamic updates to your fields on every request, at the expense of performance.submittingForm
,createdSubmission
,submittedForm
The
submittingForm
,createdSubmission
, andsubmittedForm
hook have been removed. Use theformSubmitted
hook instead.Events
The
submissionCreated
Livewire event has been removed. You should listen for theform-submitted
event instead.Field models
Field models have been substantially refactored. Each field now holds and processes its own value when the form is submitted.
$fields
public propertyPreviously, we used the public
$data
property for storing the data of a form. This property has been removed in favor of the$fields
property. This property contains all the field model classes with their properties and values.This change affects validation and custom messages. So you should update accordingly:
Validation in your form blueprints
Messages in your custom form components
Renamed model
You should update the checkboxes field model binding in
config/livewire-forms.php
:label
propertyThe
label
property has been renamed todisplay
. If you are programmatically setting this property, you should update your code accordingly.showLabel
propertyThe
showLabel
property has been removed. If your project relies on it, you may always add it back yourself.Property methods
If you are setting a field property in a form component or view, the value is now passed through and processed by the respective property method. If you've got your own models with custom property methods, you should update those methods to accept a value so it can be processed:
If a property method doesn't accept an argument, the property will be considered read-only.