How to repeat a form

Hi,

I want to create a simple add button in a table to transfer a database record to another table.

I cannot find out how to do this. In PHP I just repeated a form. How would I do this with Wappler? I can’t find out how to repeat a form.

Thanks for your help in advance.

You can repeat a form in wappler as well.
Add a hidden field and a submit button inside it, and just run the Insert (or update) server action on submitting this form. Store the record id in the hidden field and send its value.

that’s how my code is at the moment

<tbody is="dmx-repeat" dmx-generator="bs4table" dmx-bind:repeat="listGeraet.data.listGeraet" id="tableRepeat2" dmx-state="stateManager" dmx-sort="sort" dmx-order="dir" key="$index">
                    <form is="dmx-serverconnect-form" method="post" action="dmxConnect/api/handwerker/insertHandwerkerOnline.php">
                    <tr>
                      <td dmx-text="$index+1">
                        <input dmx-bind:name="HTGeraetId" type="hidden" class="form-control" dmx-bind:value="HTGeraetId">
                      </td>
                      <td dmx-text="HTGeraetName"><input dmx-bind:name="HTGeraetName" type="hidden" class="form-control" dmx-bind:value="HTGeraetName"></td>
                      <td dmx-text="HTGeraetGruppeName"><input dmx-bind:name="HTGeraetGruppeName" type="hidden" class="form-control" dmx-bind:value="HTGeraetGruppeName"></td>
                      <td>
                        <input dmx-bind:name="HTGeraetGruppeId" type="hidden" class="form-control" dmx-bind:value="HTGeraetGruppeId">
                        <button class="btn btn-outline-success btn-sm" type="submit"><i class="fa fa-plus-circle"></i> Hinzufügen
                        </button>
                      </td>
                    </tr>
                      </form>
                  </tbody>

Ok, so what is the issue currently?
BTW you can just move the form in the last cell where the button is.

nothing happens. I will try to move the form.

If nothing happens i will need a link to this page and test what’s wrong.

https://link.edited/index.html

Can you provide some screenshots of how is your insert action setup?

image

I changed a couple of things, but still no success.

That is how the code is at the moment:

<form is="dmx-serverconnect-form" method="post" action="dmxConnect/api/handwerker/insertHandwerkerOnline.php" dmx-on:submit="bs4form.submit();listGeraetOnline.load({sorto: query.sorto, diro: query.diro},true)" id="form">
<input dmx-bind:name="PHTGeraetId" type="hidden" class="form-control" dmx-bind:value="HTGeraetId">
<input dmx-bind:name="PHTGeraetGruppeName" type="hidden" class="form-control" dmx-bind:value="HTGeraetGruppeName">
<input dmx-bind:name="PHTGeraetGruppeId" type="hidden" class="form-control" dmx-bind:value="HTGeraetGruppeId">
<input dmx-bind:name="PHTGeraetName" type="hidden" class="form-control" dmx-bind:value="HTGeraetName">
<button class="btn btn-outline-success btn-sm" type="submit"><i class="fa fa-plus-circle"></i> inzufügen     </button>
</form>

I see some strange event on form submit - bs4form.submit(); this should not be there. Please remove it.
Also please enable output option for the insert step in server connect.

removed, but still no success

I still see it on your page and it causes an infinite loop!

do you still see it? I can’t find it in the code.

Yes it is still on your page on the link you sent earlier:

<form is="dmx-serverconnect-form" method="post" action="dmxConnect/api/handwerker/insertHandwerkerOnline.php" id="form" dmx-on:submit="form.submit();listGeraetOnline.load({sorto: query.sorto, diro: query.diro},true)">

Should I put the dmx-on:submit=“form.submit()” on the button? I removed it from the form

No Marcel,
You should not be using this action anywhere in the form. It’s app connect which submits the form on submit, remove this action from the submit button as well!

And you can bring back the onsucess event which reloads the server action on the page listing the records.

Puh… :slight_smile:

action removed an added nonsuccess event. still no success.

I will check your page and will get back to you.