Setting default value in input with createOptionForm
The ->default(fn (Get $get): ?int => $get('state_id')) in following code returns $get('state_id') as null, even though I select a value in state_id select, how can I prefill an input in the create createOptionForm modal with the value from another form field?
Solution:Jump to solution
That's because the $get in that context is the form in the createOptionForm modal, not the parent form. So you are just getting the same state_id you are trying to set a default on.
I don't know if this will work, but you could try something like ...
```php...
2 Replies
Solution
That's because the $get in that context is the form in the createOptionForm modal, not the parent form. So you are just getting the same state_id you are trying to set a default on.
I don't know if this will work, but you could try something like ...
Yes, it works, thank you!