Live field re-render problem ?

Good evening, I'd like to set up a rather special system, which would allow, depending on certain conditions on a record, to display "helperText" and perform actions on fields, e.g. deactivate, change labels, hints, etc... So I use the "afterFill" method, and make my modifications. This works at first, but as soon as another field is reactive, the form is completely re-rendered, which causes me to lose the state. This behavior seems normal with Livewire. Is it currently possible to prevent this behavior? If so, how? Is there any other way of solving this problem? I don't want to do this in a unitary way on each of the fields, but to be able to do it before rendering my form. The video shows a demonstration of the problem. Thanks a lot!
2 Replies
LeandroFerreira
LeandroFerreira9mo ago
You don't need to use it in afterFill, just use disabled() in the field
->disabledOn('edit')
->disabledOn('edit')
or via closure
->disabled(fn($operation):bool => $operation === 'edit')
->disabled(fn($operation):bool => $operation === 'edit')
Nukacola
Nukacola9mo ago
Thank you for your answer, indeed, I know that it is possible to intervene individually on each of the fields. On the other hand, I do not want to do it because it significantly weighs down the code, hence the fact that I proceed from the « afterFill » I imagine myself making a request from the field I am currently modifying to retrieve a list from another table (database) containing itself, the fields that are disabled with the deactivation comment. If I had to do the processing unitarily by field, and since the fields may vary in my database, I will find myself making a query at each rendering of the fields, which makes the processing very heavy. My record -> hasMany DisabledField In table : field_name | comment up
Want results from more Discord servers?
Add your server