How to change a value of a form field in Form Blocks (React version)

Form blocks are listening to a special event called update-fields.
When block is loaded block-loaded event is triggered after which one can set form field values in name, value pairs and trigger update-fields event.

<script>
window.addEventListener('block-loaded-form1', () => {
	const updateFields = new CustomEvent('update-fields-form1', {
			detail: {
				'Full Name': 'Softr',
				'Email': 'info@softr.io'
			}
	});
	window.dispatchEvent(updateFields);
});
</script>

form1 is the name of the block set in the softr studio block settings panel.

2 Likes

Thanks for sharing Arthur!

Is it possible to hide fields in Forms Blocks? What other events do Form Blocks listen to (other than update-fields); anything like hide-fields or show-fields?

Thanks,