#Where to put afterFormValidated()??
39 messages · Page 1 of 1 (latest)
I don't see a form action in the code generated by artisan. Do I need to add one somewhere?
You won't because we handle all that but you will see a create action within the ListPage
Huh wha? In english please? I search my entire package and see no 'ListPage'
That is in english.
What command did you run exactly?
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
Tell me EXACTLY the command you ran.
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
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.
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
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
it creates subdirectory with pages, yes
So within the CreatePage you will add a function in there
The only thing in that file is a function getHeaderActions()
ok, does it have to have a specific name? (an override?)
uh ok, and how does filament know to run it?
it would look similar too
class CreateFont extends CreateRecord
{
protected static string $resource = FontsResource::class;
// afterFormValidated function
protected function afterFormValidated(): void
{
}
}
oh ok, that makes sense
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.
what parameters are available? I'm assuming Get/Set anything related to file upload?
No need for them really, it's page so just use $this
Look in CreateRecord.php for more details/info
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();
}
}
??
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!
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