Manipulate form inputs through code

Hi,

I am trying to update form input fields in my plasmic codegen project. I got most things working, such as catching the onChange events (which can’t be caught through plasmic studio, because they don’t fire on form fields).

However, I am not able to assign values back to the input field through the value prop. I found this post here, which seems to indicate that this is not possible at all through the input field itself, but only through the form item?

I am wondering how this would look like for a working example. In my case, I use a simple page with a form and its fields, no components involved (besides the standard form components itself), which looks simplified like this.

One more thing that I noted is, that the state always lags by one letter. Meaning, I set it in the function and when I do a console.log, the last letter is always missing. The event target has it though.

Any ideas or suggestions? Thanks a lot

function InvestmentEdit() {
const [myField, setMyField] = useState(“”)

<PlasmicInvestmentEdit 
 onChange((event) => {
  ... // code in here does capture form events, e.g.
  setMyField(e.target.value)
  console.log(e.target.value) // correct value
  console.log(myField) // missing the last letter
}
 field = {{
        props: {
        value: myField, // this doesn't work, value is not populated into the field
        onChange: (e:any) => {
         ... // code is properly running
      }
}}

    />
  </PageParamsProvider__>
</GlobalContextsProvider>
);
}