Using $set on hidden field

Is there a reason why it's not possible to set the value of a hidden field (i.e.: Forms\Components\Hidden) using $set so that the value is visible from JavaScript in the normal manner? I've some code that works as expected when using a normal text field (as a quick visual debugging mechanism), but which fails when the form element is set as hidden. Is this expected behaviour?
3 Replies
Mohamed Ayaou
Mohamed Ayaou4w ago
Even if I agree that this shouldn't be the case but the Hidden field is not meant to a frontend dynamic reactivity, you have to move your logic to the ->mutateFormDataUsing() in the CreateAction or in your CreateRecord.php file for your resource Just Move the logic to the backend.
John Parker
John ParkerOP3w ago
@Mohamed Ayaou That's sadly not always realistic when you're dealing with things such as Google Maps, hence the need to also handle the logic on the frontend.
Mohamed Ayaou
Mohamed Ayaou3w ago
you might just use a regular textInput field that is with ->hidden() but still dehydrated

Did you find this page helpful?