Hoppa till huvudinnehållet

How to access a workflow value in custom React Form Element code

Kommentarer

3 kommentarer

  • Ryan Cooney

    Typically you are going to need to use the Set Form Element Property activity in the load event of your custom form element.

    Consider the Star Rating Custom Form Element implemented here: https://developers.vertigisstudio.com/docs/workflow/tutorial-web-implement-star-rating-form-element. The props of this custom component look like this:

    interface StarRatingProps extends FormElementProps<number> {}

    That <number> means that the “value” prop is a number, so this form element accepts a numeric value. 

    To set the value prop at runtime we would use the Set Form Element Property activity with:

    • Property Name: value
    • Property Value: =$value1.result

    If the built-in “value” prop is not appropriate for your custom React component feel free to add whatever props you expect, for example: username: string;. Then when using Set Form Element Property set the Property Name to be the name of the prop you want to assign.

    1
  • Jeffrey Li

    Hi Ryan,

    This solution worked, thank you for your help. Cheers

    0
  • Ryan Cooney

    Glad you are up and running. 

    I've added a section to the docs on how to set the value (or any other prop) of a custom form element at runtime here https://developers.vertigisstudio.com/docs/workflow/tutorial-web-implement-star-rating-form-element#set-the-form-elements-value-at-runtime.

     

    1

Du måste logga in om du vill lämna en kommentar.