Updating Form Field data from JavaScript

Is there any means of accessing Form Fields from JavaScript? I need to be able to update the field contents and trigger a "has updated" event or similar from JavaScript. I know you can do this for Livewire components, but the Filament form fields don't appear to be exposed in this manner from what I can tell. I can of course simply update the DOM elements accordingly, but this feels wrong. More fundamentally, is there a better approach to enabling interaction between JavaScript code and Fields?
1 Reply
Sanchit Patil
Sanchit Patil15mo ago
following.. I am in the same same boat. what I am doing currently is, (not happy at all with this though)
let fieldInput = document.querySelector('.fieldclass');
fieldInput.value = datatoupdate;
fieldInput.dispatchEvent(new Event('input'));
let fieldInput = document.querySelector('.fieldclass');
fieldInput.value = datatoupdate;
fieldInput.dispatchEvent(new Event('input'));

Did you find this page helpful?