Fill form data when a specific field changes
Hello,
I have this form:
I want when hourly_price value changes I calculate the daily_price and monthly_price and fill them automatically. How can I implement this? I tried using
afterStateUpdated
but it seems that I cannot access all the form data and manipulate the values.7 Replies
In your
afterStateUpdated
use Set $set
to change the value of other fieldsSolution
You will also need to make ‘hourly_price’ ->reactive()
Can I access the value
daily_price
inside TextInput::make('hourly_price')->afterStateUpdated(...)
? is seems that state returns only the value hourly_price
state returns only the input of hourly_price
use $get closure
$state only applies to that specific field. So you use $get and $set to manipulate other field values.
Thank you so much guys 👍