Delete Two Records: Each From Different Tables

For some reason, the following does not delete the two records that reside in two tables.

I have a table that contains service records, and another table that contains the service status records.

The status record table uses a foreign key (service_id) from the service table. I also have a delete button that opens a modal that gives the user a prompt to ask for a confirmation to delete the records.

Can I delete both records with one delete button that executes the form that deletes the records using the following:

So far this doesn’t work. So I am appealing to anyone who may have a solution. Thank you very much!

Hi JR.

Does hiddenfield get a value from the form?

In other words, do you have a form input with a name of hiddenfield getting the required value? Unhide the input to make sure.

<!-- DELETE FORM -->
<span class="float-right">
<form name="delete_record" method="post" is="dmx-serverconnect-form" action="../../dmxConnect/api/Service/service_delete.php"
dmx-on:success="modal1.hide();sc_service_list.load({});get_id.setValue(0)">
<input type="hidden" name="hiddenfield" dmx-bind:value="service_id">
<button href="#" class="btn btn-block btn-danger" type="submit">
&nbsp; &nbsp; 
<i class="far fa-trash-alt fa-2x"></i> &nbsp; &nbsp; </button>
</form>
</span>
<!-- DELETE FORM -->

I just changed the type to text and I didn’t see the ID was there. Apparently it isn’t.

Should I select the output box? That didn’t work either.

It looks like the hidden field does not get a value. When I see
<input type="hidden" name="hiddenfield" dmx-bind:value="service_id">
where does the value of service_id come from?

Edit: as a test, replace the value with a number corresponding to the records that you want to delete.

The service_id should come from :

<dmx-serverconnect id="sc_service_list" url="../../dmxConnect/api/Service/service_list.php"></dmx-serverconnect> 

I inserted the record id # as suggested. However, still no reaction from the modal.

Assuming that record_id is a number, change the following to a number:

image

Sorry, that didn’t work. Would the modal being inside a table with a repeat be the problem?

If you have uploaded the site, could you give us the link to it. Alternatively, paste the code for the whole table and repeat area here. That way we may be able to see the problem for ourselves.

Okay, how can I privately send the link to you?

The problem is that the record ID is not selected when the trash can is clicked.

One way (probably the better way) to do this is shown in @Teodor’s tutorial:

The way that I have done this prior to the Flow component is to assign a Data Detail component. If you prefer to do it that way, then come back here and I will show you.

I’ve tried several of these too. I just can’t get the foreign key from the table into that hiddenfield post. When I use sc_service_list.data.service_list[0].service_id, I get the last ID in the table. I just don’t know how to capture the service_id in sequential order. Ha!

I may need to learn how to use the $key, $index, etc.?

Thanks again for your kind help!

Hi @revjrblack
What exactly do you have on your page - a repeat region and a button which opens a modal which holds this hidden field? So when you click a record in the repeat, it should populate the selected record in this hidden field?

Yes, I have followed the tutorial on using the hiddenfield as a post variable, etc. It works fine with all but this particular arrangement. I believe it might be due to the use of two different tables in the repeat? Ben help with some of it, however when he pointed out your video that uses FLOW, I am currently trying it to see if it works.

With the previous attempts I was having a difficult time with the right syntax of the service_id that linked to the record that was to be deleted.

What do you mean? How do you use two different tables in the repeat?

Why not just use detail region and set the hidden input value on click as explained here:

Instead of binding the text in the modal use the dynamic value for the hidden field.