Hoppa till huvudinnehållet

How does one remove a form element?

Kommentarer

2 kommentarer

  • Permanently deleted user

    I've figured out how to do exactly what I wanted. I was being thrown by the "reset" property of the DisplayForm activity, which I'd assumed would default to "false" but in fact does not (ps if someone could throw that into the documentation that would be great).

     

    I did it from dynamically generated buttons in the form too, btw. For those not in the know, there is no way (or at least, not that I know of but if you know please let me know) to copy a form element's event workflows into a new form element object, so a dynamically added button bar will automatically use the "submit" logic on the form.

     

    To remove a form element, put any info that you need into the value of that form button when you add it and then check for that value after the form has been submitted. In my case, that value was an identifier for a section of elements to remove. Looped over the form.state to find the elements of interest and hit them with the delete operator and I was good to go; no custom activities necessary. Just make sure that your form isn't resetting when you return to it, like me 😅 .

    1
  • Zack Robison

    I used to use the same method to remove form elements, but figured I'd try to just delete one today in a subworkflow and I got it.  So for the next dev: you can now use an Evaluate Expression activity "= delete $form.state.element" followed by another evaluation "=$form.actor.refresh()" to make this happen.  There's no need to submit the form and loop back anymore.  Not sure when that changed, but I'm not complaining.

    0

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