Default values in form

hi,
I can’t find an example that shows me how to define default values in a form. I’ve tried setting it in the backend but that doesn’t seems to work. I’m guessing it is something trivial but I’m pretty new to this stuff. Any help please? :smiley:

I’m using gradle - spring boot - hilla - reactjs, thanks

Fernando

One very straightforward way is to create a TypeScript object that contains the default values and then read that object to do the initialization. As a simple example, you could do that in an useEffect to load the defaults every time the view is rendered:

export default function PersonView() {
  const { read } = useForm(PersonModel);

  useEffect(() => {
    read({name: 'Bob', job: 'Hilla developer'});
  }, [])

  // ...
}
1 Like

There is also a recently updated guide that covers just this: How to use fields and data binding in Hilla | Vaadin.