Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class "Aerni\LivewireForms\Fields\Checkbox" not found #77

Open
thomassausen opened this issue Jan 8, 2025 · 3 comments
Open

Class "Aerni\LivewireForms\Fields\Checkbox" not found #77

thomassausen opened this issue Jan 8, 2025 · 3 comments

Comments

@thomassausen
Copy link

Hi there,

one Statamic installation has the problem, that if you try to enter the contact form, you only got the following error message:

Class "Aerni\LivewireForms\Fields\Checkbox" not found (View: /var/www/html/vendor/aerni/livewire-forms/resources/views/dynamic-form.blade.php)

  • PHP 8.2.24
  • Laravel 10.48.25
  • Statamic Pro 5.45.1
  • Livewire Forms 9.4.1
  • Livewire 3.8.1

It wasn't my site, I never used your plugin. I am just the new tech guy trying to find out, why the form is not working.

@aerni
Copy link
Owner

aerni commented Jan 8, 2025

The class Aerni\LivewireForms\Fields\Checkbox doesn't exist in the latest version. Looks to me like your site is using the latest version without having followed the Upgrade Guide. Make sure to give it a read and apply the code changes accordingly.

As for the checkbox, you should update the checkboxes field model binding in config/livewire-forms.php:

- \Statamic\Fieldtypes\Checkboxes::class => \Aerni\LivewireForms\Fields\Checkbox::class,
+ \Statamic\Fieldtypes\Checkboxes::class => \Aerni\LivewireForms\Fields\Checkboxes::class,

And also rename the view checkbox.blade.php to checkboxes.blade.php.

@thomassausen
Copy link
Author

thomassausen commented Jan 9, 2025

Okay, thank you. That helped with this error.

If I try to view the contact form now, I am getting:

"Livewire \ Exceptions \ PropertyNotFoundException

Property [$component] not found on component: [contact-form]"

This is strange for me, because the page has just:

{{ livewire:form handle="contact" view="contact" }}

Which should be fine. So when I check the contact.blade file

<form wire:submit.prevent="submit" class="w-full max-w-2xl" x-data="{formData: []}">
    <div class="grid grid-cols-1 gap-2 md:grid-cols-12">
        @formField('interesse')
        @formField('name')
        @formField('email')
        @formField('nachricht')
        @formField('rueckrufbitte')
<div x-show="formData.Rueckruf" class="col-span-1 md:col-span-12 grid grid-cols-1 gap-4 md:grid-cols-12 mt-4">
            @formField('telefon')
        </div>
        <div class="col-span-1 md:col-span-12 grid grid-cols-1 gap-8 md:grid-cols-12 mt-4">
            @formField('datenschutz')
        </div>

        <input type="text" name="honeypot: kontakt" class="hidden" />

If I delete all "@formfield()" snippets, the page is rendered (without the form, because no fields are there to be rendered"

But @formfield('xy') should be correct to display the fields. And all fields are in the fields blueprint.

@aerni
Copy link
Owner

aerni commented Jan 9, 2025

It looks like the contact.blade.php view is outdated. That's likely why you're seeing this error. Please closely follow the Upgrade Guide. In this case, specifically the section Themes and views.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants