The selected {field} is invalid?
I keep getting this error saying that the selected fields are invalid whenever I try to submit this form. The form is located within a custom page.
This is part of my form, but the rest of it is similar/the same:
22 Replies
Did you try like this and remove
->default(De..)
from select?
Yes I did but I found out that the "relationship()" method was causing it. The regular
options()
method worked but idk why not relationship. And this happens when I use the searchable()
and default()
with the options now.
Never have these issues when using Resources...
And when clicking submit it says wrong integer value for them because there are multiple options with the same integer
Try removing the defaults does that solve it? If so, try adding the defaults as part of the form fill
You could also remove the defaults form the options
Only until I removed the
searchable()
and also use disablePlaceholderSelection()
then the right options are available, but then it makes the default the wrong default...
Bank of America is supposed to be the default like beforeThis is kinda frustrating ngl
What is the result if you use like this?
Hmm, default doesn't work by default when loading with data. are the accounts sorted in order?
It is frustrating, I have seen it in the #althinect-spatie-roles-permissions when editing and adding permissions too.
It just gives me multiple values that are the same like before. Even when I chose the correct one when I got to the point of removing searchable, etc, when clicking submit it would say “wrong integer value for account_id”, etc… which makes so since.
I don’t think so but that shouldn’t matter to be honest, but do you think choices js is confusing option position values with the ID’s of the values in the database and multiplying them? Because I’ve noticed that when using “options()” with integers (Id) for keys and not strings the select field has issues a lot of the time
Weird, I have 4 Input and 3 Select in my custom page, but I didn't have any error though.. for last, can you show your local scopes
getAccounts()
because I'm also curious 😆These are defaults:
This is what shows when I dd(getAccounts())
And this is literally what shows in the form when using that.
Here you have 3 data, but in select UI you have 4 options.. this may be the cause of the error.. not sure tho
I think its because when plucking an ID as the key, and when trying to use the default value you have to use that key as the default but the default has to be a string not a integer value
or else it will use the key position and not its actually value
Yeah nevermind because this worked so I suppose it was this
Then change here ->get(['name', 'id'])->first()..... return $defaultAccount ?? null
That's great if it's working..
Haha so I was using
defaultAccount->name ?? null
before but its actually ID omfgI need some sleep lmao
Thank you for all the help tho haha, its always the simple things
WC, glad you found out..