Generic admin panel (not related to table/model)

How does one create an admin 'utility' page/panel/widget/whatever that is not related to an existing model/table or the database? (all the help pages I can find seem to relate to dealing with laravel models) I have a tool I use in conjunction with a management back end that generates an svg file from text. I'd like to wrap it in with the other admin tools for that package/plugin. I'd like to use the filament form builder tools if possible to do it. (I already have functions ready to generate the select options/values I need for a form)
Solution:
did you try adding this trait use InteractsWithForms;
Jump to solution
13 Replies
treii28
treii28OP4mo ago
I tried to build both a basic resource and a widget. The latter seems to require the resource to load, and the resource won't load because there's no model in this particular laravel package. (the package is just the tool that generates the svg from text) Using the web page instructions, it seems to set up something assuming there is an 'Svgtext' model somewhere and loading the page dies when it tries to run query() on a table that doesn't exist.
Dennis Koch
Dennis Koch4mo ago
I'd like to use the filament form builder tools if possible to do it.
Forms don't require a model. You can do whatever you want with that data in the submit method. Inside the Panel you can just generate a Page which is a Livewire component
treii28
treii28OP4mo ago
I didn't say anything about needing a modal. So how do I use the Filament Form goodies in a page? And then how do I tie that page into the admin panel? when I use the artisan make:filament-page it seems to be back to square one wanting me to attach it to a resource (that won't load beause there is no model)
Lara Zeus
Lara Zeus4mo ago
wanting me to attach it to a resource
its optional, just press enter
treii28
treii28OP4mo ago
In the meantime i started playing in a widget, and I'm getting a form, but it's requiring some re-adjustment. It seems when i try to implement hasForms it requires a whole lot of function implementations. My IDE was able to fill in stubs for them that I tweaked with default values, but getForm doesn't seem to be behaving as per examples I found online. I think the examples are referring to version 2. What is the proper way to generate such a form in a widget (as in, where do I get the schema and how do I get it from the widget data into the blade file?)
Solution
Lara Zeus
Lara Zeus4mo ago
did you try adding this trait use InteractsWithForms;
treii28
treii28OP4mo ago
Hmmm, that example is resulting in the same issue in my IDE. That implement is demanding a whole lot of functions and their example only shows one or two.
treii28
treii28OP4mo ago
No description
treii28
treii28OP4mo ago
ahhh, the 'use InteractsWithForms' fills in a lot of those blanks That helped quite a bit, thanks! Tracing that library, I love how it abstracts that stuff. Although I already have learned enough to know overriding form() is probably not as optimal as using getFormSchema()
Lara Zeus
Lara Zeus4mo ago
did you try adding this trait use InteractsWithForms; inside the class!
treii28
treii28OP4mo ago
Yeah, commented on that above. But now I'm having a hard time trying to figure out how to pre-populate the form with default values/selections. I tried ->default('value') but it's not working OK, managed to get those working with a little dinking around and learning why they overrode 'form' Now my next question is, how do you put the form in a separate class so it can be re-used in different components/widgets? I saw a getFormModel but couldn't find documentation on how it worked.
Dennis Koch
Dennis Koch4mo ago
getFormModel is probably for the actual model used.
Now my next question is, how do you put the form in a separate class so it can be re-used in different
Just put it in a class and call a static method that return the form schema Something like this:
public function form(Form $form) {
return MyNiceForm::get($form);
}
public function form(Form $form) {
return MyNiceForm::get($form);
}
Want results from more Discord servers?
Add your server