Hide form on submission success

Is there a way to hide a form on success? I want to be able to fill out the for and then hide the form and display a success message.

I would think this would be easy to accomplish. I know I can probably get AI to instruct me, but I'd rather engage in the community.

Thanks :beers:

I'd just had a hidden input and populate it with 1/0 based on success, then a show/hide based on the value of the hidden input Brad. That way can always reset the hidden input easily. If you want persistence then use a cookie or local storage item to store the value.

That makes sense, cheese. But can you set a form field vale to a field after the form has been submitted? I'm not sure I can use a cookie or local storage as it is in a dashboard application where the form will be available from a client profile. So staff may fill out the form for one client and then go to another client profile and fill out the form again.

Yes just use a Dynamic XHR Event on success Brad then set the value.

Was a suggestion if you wanted it persistent so it didn't show again.

Do you apply the dynamic event directly to the form action? I can add the success but I don't have access to the form in the attributes?

Select the form and then click Dynamic Events Brad. Is based on the XHR response from the Action success.

Yep, I found that part, but when setting the action for on success I don't have access to the form to be able to set the value of the form field.

Did you click the little play icon:

Then you should see:

1 Like

That is what I was expecting to see, but the form is not in the list. I obviously have something set up wrong. Thanks for your guidance. I think that should work and would be my best bet, just have to figure out why the form isn't showing in the list.

I will work on it. Thanks again for your help. Much appreciated.

1 Like

Here you go Brad, just add this to the form tag and create a hidden input called formSuccess in the form itself:

 dmx-on:xhrsuccess="formSuccess.setValue(1)" dmx-hide="(formSuccess.value == 1)"
1 Like

I just checked with a different form and I have all of the options as it should. So something is wrong with my form.

Did you convert it to a Server Connect form? Easy to forget when your brain is busy.

Thanks Brad and Cheese — the discussion helped me think through the flow more clearly.

I ended up taking a slightly different approach using an App Connect variable to track the submission state. It keeps everything declarative and can be set entirely through the Wappler UI, which I found made the setup a bit simpler for this particular use case.

<dmx-value id="form_submitted" dmx-bind:value="false"></dmx-value>

Then the form wrapper uses:

dmx-hide="form_submitted.value"

And the success wrapper uses:

dmx-show="form_submitted.value"

Finally, the form sets the flag on success:

dmx-on:success="form_submitted.setValue(true)"

To click here to see it in action

Cheese’s example works well too, I just found this UI‑driven pattern a nice, clean alternative.

Appreciate the input from both of you.

3 Likes

Thanks Ben! That is exactly what I am trying to achieve! I will try and recreate this.

Much appreciated!