MH2ag
February 25, 2019, 9:21am
1
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.
Teodor
February 25, 2019, 9:31am
2
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.
MH2ag
February 25, 2019, 9:34am
3
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>
Teodor
February 25, 2019, 9:36am
4
Ok, so what is the issue currently?
BTW you can just move the form in the last cell where the button is.
MH2ag
February 25, 2019, 9:37am
5
nothing happens. I will try to move the form.
Teodor
February 25, 2019, 9:38am
6
If nothing happens i will need a link to this page and test what’s wrong.
MH2ag
February 25, 2019, 9:43am
7
Teodor
February 25, 2019, 9:45am
8
Can you provide some screenshots of how is your insert action setup?
MH2ag
February 25, 2019, 10:21am
11
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>
Teodor
February 25, 2019, 10:24am
12
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.
MH2ag
February 25, 2019, 10:26am
13
removed, but still no success
Teodor
February 25, 2019, 10:27am
14
I still see it on your page and it causes an infinite loop!
MH2ag
February 25, 2019, 10:30am
15
do you still see it? I can’t find it in the code.
Teodor
February 25, 2019, 10:31am
16
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)">
MH2ag
February 25, 2019, 10:37am
17
Should I put the dmx-on:submit=“form.submit()” on the button? I removed it from the form
Teodor
February 25, 2019, 10:38am
18
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.
MH2ag
February 25, 2019, 10:48am
19
Puh…
action removed an added nonsuccess event. still no success.
Teodor
February 25, 2019, 10:49am
20
I will check your page and will get back to you.