Replies: 2 comments
-
I was looking through the discussions to see if this issue was already highlighted. I also cannot get the newly created option to be automatically selected by the On your other question - you can pass in data from the main form to the modal form by using $get in the same way you do for the
Select::make('city_id')
->label('City')
// ...
->createOptionForm(function (Get $get, Form $form): Form {
$stateName = State::find($get('state_id'))->name;
return $form->schema([
TextInput::make('name')
->label(fn() => "Add a city for the state {$stateName}"
->required(),
];
}) I have a similar set up working (except for having the new entry auto-selected!) on Filament 3.2.96. |
Beta Was this translation helpful? Give feedback.
-
I know this Discussion is pretty old, but I stumbled across it while looking for a solution to the same problem. Not really a proper fix, Just set Select::make('author_id')
->relationship(name: 'author', titleAttribute: 'name')
->createOptionForm([
// ...
])
->createOptionUsing(function (array $data): int {
return auth()->user()->team->members()->create($data)->getKey();
})
// Workaround to make auto-select of freshly created Options work:
->native(false), Caution!! By setting native(false), you enable the JS-powered select. |
Beta Was this translation helpful? Give feedback.
-
I have a basic Country, State, City set up on my resource.
Since there are far too many cities to prepopulate, I would like this to be added by the user, but also display preexisting cities to avoid duplicate entries.
I figured out how to add a new city, but why doesnt that newly added city become the chosen selection?
And is there a way to set the modal to say "create city for {State} to help users know that they are adding a city within the correct state. On Testing, I forgot to change the state, and ended up adding the city that doesnt belong in that state.
Is there a suggested way to help verify that the entered city is correct, and give them an option to undo the addition if added accidently as I did?
Beta Was this translation helpful? Give feedback.
All reactions