johncarter/statamic-livewire-forms

There is no license information available for the latest version (v1.0.2) of this package.

Use Laravel Livewire to submit forms created in Statamic CMS.

v1.0.2 2023-09-20 08:12 UTC

This package is auto-updated.

Last update: 2024-04-20 09:32:09 UTC


README

This addon allows you to submit forms in Statamic CMS using Laravel Livewire.

Installation

Install the package via composer:

composer require johncarter/statamic-livewire-forms

Usage

Include Livewire styles and scripts:

<html>
<head>
    <!-- /... -->
    {{ livewire:styles }}
</head>
<body>

    <!-- /... -->
    {{ livewire:scripts }}
</body>
</html>

Run command to generate the view:

php artisan statamic-livewire-forms:make:view

Or, create the view manually in /resources/views/livewire/form-view.blade.php.

Bind properties in the view like this:

<input autocomplete="name" type="text" wire:model.lazy="data.name" />
@error('data.name')<div>{{ $message }}</div>@enderror

Embed the livewire component in your template:

{{ livewire:statamic-form handle="contact_form" }}

If no view parameter is set, the component will default to the kebab case of the form handle e.g. /resources/views/livewire/contact-form.blade.php

Notes & Limitations

  • Only tested with text and textarea form fieldtypes.
  • Not tested on multisites
  • Not tested using any static caching strategies.

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

The MIT License (MIT). Please see License File for more information.