#Where to put afterFormValidated()??

39 messages · Page 1 of 1 (latest)

lost snow
#

afterFormValidated would be on the form/action.

But the create command comes from the ListPage which is in the headerActions.

->actions([]) on the table will be rendered on each row.

latent star
#

I don't see a form action in the code generated by artisan. Do I need to add one somewhere?

lost snow
#

You won't because we handle all that but you will see a create action within the ListPage

latent star
#

Huh wha? In english please? I search my entire package and see no 'ListPage'

lost snow
#

That is in english.

What command did you run exactly?

latent star
#

All I need to know is where/how I add this functionality within the structure created by artisan

#

the documentation gives and example of the code but no clue where to put it

lost snow
#

Tell me EXACTLY the command you ran.

latent star
#

huh? I haven't written the full code yet because I can't figure out where it should even go. I'm just creating an empty function with a break point at the moment

#

I'm uploading a file and I have a function that will convert the file into multiple file formats.

#

I'm uploading fonts and need them in SVG, TTF and WOFF formats

lost snow
#

See here:

The Resource generated by the artisake make:filament-resource command seems to have a table section with

What command did you run exactly.

latent star
#

I am clicking submit on the form. I don't understand what you mean by 'what command did you run exactly''? I did a ./artisan make:filament-resource --generate

#

FontResource being the target name

lost snow
#

So that is the exact command

#

This means you have the pages, and when you create you get a new page correct?

#

A page will be in:

app\Filament\Resources\FontResource\Pages\ListPage.php

latent star
#

it creates subdirectory with pages, yes

lost snow
#

So within the CreatePage you will add a function in there

latent star
#

The only thing in that file is a function getHeaderActions()

#

ok, does it have to have a specific name? (an override?)

lost snow
#

No...

#

In the CreateFont.php

#

you add the function

latent star
#

uh ok, and how does filament know to run it?

lost snow
#

it would look similar too

class CreateFont extends CreateRecord
{
    protected static string $resource = FontsResource::class;
    
    // afterFormValidated function
    protected function afterFormValidated(): void
    {
        
    }
}
latent star
#

oh ok, that makes sense

lost snow
#

Because filament is OOP setup with Dependancy injections

#

The CreateRecord that is extended has it and you extend it within the new class.

#

But what you are doing sounds like the ideal use for SpatieMedia where you can tell it to create multiple versions.

latent star
#

what parameters are available? I'm assuming Get/Set anything related to file upload?

lost snow
#

No need for them really, it's page so just use $this

#

Look in CreateRecord.php for more details/info

latent star
#

OK, added the function to CreateFont - added a breakpoint - tried to create a record and hit save. NOthing

#

the only reference I can see to that page in artisan generated code in the Resource file is in getPages()

#

<?php

namespace Treii28\SvgtextFilament\Resources\FontResource\Pages;

use Filament\Resources\Pages\CreateRecord;
use Treii28\SvgtextFilament\Resources\FontResource;

class CreateFont extends CreateRecord
{
protected static string $resource = FontResource::class;
protected function afterFormValidated(): void
{
xdebug_break();
}
}

#

??

latent star
#

OK, so this forum is apparently as useless as the documentation - give you just enough information to frustration the @#$%(#$%^( out of you and leaves you with code that still ISN'T WORKING!

charred condor
#

There are no dedicated resources to answer questions on this server - we are just trying to help each other. You asked a question and, when you hadn’t received a response at 59 minutes, you make a post like this. Your expectations are unrealistic. Have a look at the resource lifecycle. If you’re trying to create additional files after saving the resource, you can hook into Eloquent events: https://laravel.com/docs/11.x/eloquent#events

Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.