Server Connect Form Reset

Normally this king of functionality is achieved easier if you put your form in a detail region and populate its data from the detail region.

So when the detail region is set to a record, the forms has data, when it is set to empty record you get an empty form for insert.

And at the end of the form you have two submit buttons - one for update and one for insert and you toggle their visibility depending if you have record or not.

So this way you gave a nice combo of insert and update form in one.

The detail region has actions for setting the active record or clearing it.

Not sure if we have a tutorial for this one but it will be very useful @Teodor

1 Like

I tried using detail region, but could not understand it. So went with auto form generator with help from other posts here and DMXzone videos.
A how-to tutorial post for this would be really helpful.

I just tested your case locally and it works perfectly well like i described above. Form > Dynamic Events > Server Connect > Success > set var.value empty:

It resets form fields (makes them empty) as soon as you update a record.

1 Like

http://wappler.slashash.co/ndxp/edittest.php

Click edit on a record. Change any value. Save.
Then click edit on same or other record, and you will see that previous record’s values are still shown while new records are being fetched.

Remove the noload option from your server action.

Then - on the edit button you have set onclick > set var value and load server action. That is wrong, you should only use set var value action there (without load server action).

Also as you have an edit button please remove the onclick event from the tr…

<tr dmx-on:click="varid.setValue(TrackID)">

Removed no load check and made changes on edit click.
Its working as expected now.
But, I didn’t understand what the issue was and what the solution is doing. Can you please explain?

Forgot about the tr click. Have removed it now.

Changing the value of the variable won’t run the server action automatically, when it’s set to noload.
You should remove it in order to auto load it, when a value changes.

This part I understood. I did not get why I cannot keep server action as noload, load it on click & reset the form at will.
The connection between auto load and form reset is unclear. Ideally, form should reset irrespective of server connection being auto load or not.

You are just confusing form reset with setting variable value …

That’s not a form reset. Form reset is when you manually enter something in an empty form, then hit the reset button and it removes what you wrote.

Your form is not empty, it receives dynamic values from the server action. In order to be able to auto reload server action when you set the variable value, you must turn off the noload option. That’s all.

1 Like