multiple() fields on /create return null
Full Disclosure: very inexperienced with Filament and php in general.
Began this project a while ago in my free time with V2+Companies plugin and plan to finish it before going for V3.
Trying to save an array of tag IDs as JSON, fields not registered (first time implementing Multiple() Filament logic). Any advice would be much appreciated 🙂
Error:
Migration
Model
12 Replies
Resource
Resource pt2
You are using
->relationship('types', 'provider')
on all your Selects which means Filament saves that data to your relationship and not a column. That's why it's empty.
If you don't want to save to the relationship, just use ->options(fn () => "query your relation data")
🤯
Will try that right now, thank you so much!
It worked!
Hope this solution (my code) is not ridiculous
Looks good to me.
Now question becomes, how do I display corresponding label names on Table view instead of ids
Thanks! I'll mark this one as resolved
If you'd use a relation, you could just do
kengu.provider
. But since you use JSON, you need to format the data yourself. You could do this via something like this: ->formatStateUsing(fn ($state) => InteriorProvider::find($state)->provider)
I'm confused to be honest. You've mentioned that saves it "to my relationship?"
I thought this line of code is supposed to just load an associated data from a table using a function specified in ORM. I'm trying to find where I learned this piece of code (trying to search V2 docs for -> relationship), but can't seem to find it...
If relation is no longer there (because I'm not using that line I suppose?), how come I get proper ID association with corresponding name for specific provider? (e.g. provider with id 2 = Panasonic if I go to /edit screen).
Sorry if that's a somewhat banal question 🙂
Was that answered by my last answer?
I understand your solution, but I'm trying to understand the logic behind it. Don't waste your time — will try to figure it out on my own!