form input default value not passed
Here is my code
Select::make('site')
->relationship(name: 'site', titleAttribute: 'name')
->default(Auth::user()->person->site_id)
->createOptionForm([
Forms\Components\TextInput::make('name')
->required(),
]),
Select displays correctly as expected but when press create get error as no data passed from this select. By default I want the select to be the logged in users site. Which it does display but goes blank when press create
4 Replies
The data is saved directly to the relationship and not included in the data for the actual model
What is best way to get the data so it can be saved with form in the database
Solution
Don't use
relationship()
if you dont' want to save it to a relationshipAh, thank you. Should of been using https://filamentphp.com/docs/3.x/forms/fields/select#returning-custom-search-results