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

x-splade-rehydrate doesn't reload content if SpladeForm submit #525

Open
p4rad0xus opened this issue Sep 28, 2023 · 1 comment
Open

x-splade-rehydrate doesn't reload content if SpladeForm submit #525

p4rad0xus opened this issue Sep 28, 2023 · 1 comment

Comments

@p4rad0xus
Copy link

  • Laravel Version: 10.17.1
  • PHP Version: 8.2.10
  • Splade JS Version (npm): 1.4.16
  • Splade PHP Version (composer):1.4.16
  • Dev environment (OS, Sail/Valet/etc): macOS Ventura, Sail

Description:

On a Blade page I use a table and a form. To create the table I use SpladeForm in the controller.

When the form is sent, the contents of the table should be reloaded using x-splade-rehydrate. Instead the page is reloaded and the new entry is displayed.
If I remove the stay attribute on the x-splade-form tag and add ->stay() to the SpladeForm instead, you stay on the page but the table is not reloaded.

I have the same behavior when I use the SpladeForm class.

Steps To Reproduce Issue:

In the frontend my site looks like this:

<div>
    <div>
        <x-splade-form :for="$form" stay @success="$splade.emit('entry-added')" />
    </div>
    <div>
        <x-splade-rehydrate on="entry-added">
            <x-splade-table :for="$table" :reset-button="false">
                <x-slot:empty-state>
                    <p>
                        No entries.
                    </p>
                </x-slot:empty-state>
            </x-splade-table>
        </x-splade-rehydrate>
    </div>
</div>

My index function in the controller:

TableEntrys is a SpladeTable.

public function index()
{
    return view('/tabel_entries.index', [
        'table' => TableEntrys::class,
        'form' => SpladeForm::make()
            ->action(route('table_entry.store'))
            ->fields([
                Input::make('title'),
                Submit::make()
                    ->label('Add')
            ])
    ]);
}

My store function in the controller:

public function store(TableEntryFormRequest $request)
{
    TableEntry::create($request->validated());
     return redirect($request->getRequestUri());
}
@p4rad0xus
Copy link
Author

If I just use the x-splade-form component in the Blade file, the rehydration works as expected.

<x-splade-form action="{{ route('table_entry.store') }}"
                            @success="$splade.emit('entry-added')"
                            class="flex flex-row items-end space-x-4"
                            stay>
</x-splade-form>

Is it in this solution possible to reset the formula if the submit was a success?

Do anyone know a solution for the rehydration by using the SpladeForm?

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

1 participant