Spatie settings not working
Before I try the spatie settings plugin, can we nest in a single page with for example tabs being the group of settings?
i.e. GlobalSettings -> TabForm->Email
18 Replies
Like this? You can just use the Tabs from the form builder
yeah!
Do you just build a single settings page with a tab and setting statePath on each tab?
I just store them all as json in
options.field_key
Oh, so how do you get them throughout the application?
I basically reuse a Page (which also contains content for frontend) and wrote a small
setting()
helper which is basically:
The json_decode(json_encode())
is just for converting array to object structure 😅Hehe I know that ;-). Just seems a bit labour intensive. Might review it later, but that will do for now. Thanks Dennis!
Dennis can I get some of your base examples of for class extends settings and the schema, not quite following how the Filament Spatie Settings plugin full integrates. We need to define the properties onto the settings class, but they cause exceptions everytime I do so. Clearly just missing a linkage somewhere
Sorry, I am not using Spatie Settings. I use a Page model which saves to a JSON file (via Orbit) 😅
I thought the nesting question was about general form nesting, sorry 🙈
But I don't think there should be an issue with nesting. What do you have so far?
You have both, right?
1) Spatie Settings class
2) Filament Settings Page
Yeah
Tried loading settings 'App\Settings\GlobalSettings', and following properties were missing: emails
Whenever I declar the public string within the settings class, I'll just research up somemore on the Spatie Settings class, I was using a different Library but prefer to use Spatie
Can you share the code of both?
Settings Page Class for filament:
Settings\GlobalSettings.php
According to the Filament spatie docs, you need to declare the public variables and then filament settings will pre-populate.
Comment out the emails declartion in the settings and it renders as normal in filament, but obviously nothing saves, yet it still says successful heh
Did you run the migration according to spatie docs?
Yeah I've got the database, actually wrote the migration custom as I need to migration so old settings.
What do you mean by "wrote the migration custom"? It's not following the spatie docs?
Is the data present in the db?
It's a copy of the spatie migration with some additions, no data exists in the table
I guess that's the issue.
It's not the issue as the table is exactly the same
But is has no data. Check this section in the spatie docs:
Ok I think I'm following now, the fields need adding to the database first
I was just assuming they would be added
YES!! Thanks a bunch Dennis. It was because no key existed in the database