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)
13 Replies
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.
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
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)
wanting me to attach it to a resourceits optional, just press enter
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
did you try adding this trait
use InteractsWithForms;
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.
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()
did you try adding this trait
use InteractsWithForms;
inside the class!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.
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 differentJust put it in a class and call a static method that return the form schema Something like this: