Using $get / $set with a Livewire::make() form component
I am desperately trying to create a modal with a select component that, when changed, can display some calculated things in the modal based on the selected amount.
This works to pass the default state of amount from coverage_amount, but amount doesn't change when the select field changes.
How can I access the current state of
coverage_amount
inside the PolicyPreview
livewire component?
Solution:Jump to solution
You could use a ViewField
```php
ViewField::make('amount')
->view('policy-preview')...
4 Replies
Try to use Livewire $livewire instead of Get $get
Thanks @BKF Dev - I really apprecaite your help. I tried that but I run in to this:
The table where I'm trying to attach this action is from within a widget on my panel dashboard (
ActiveCasesTable
)
At the end of the day, I'm trying to create a modal with a select field (for an amount) and then show associated fees in the modal before the user clicks save. Maybe I'm going about this all wrong. I've tried using custom modal content (and custom modal footer content) with alpine + a select field and I'm able to obviously make that reactive and update fees when the select is changed, but I couldn't find out how to pass that as the $data when the modal was submitted..
I also tried to do everything in a Livewire::make() component - but again, I don't have anything in the ->action() method .. $data is always an empty array.Solution
You could use a ViewField
And use afterStateUpdated in the select to set the value
Fannntastic! This works - and it's exactly what I needed. I can't thank you enough!