DMXzone Server Connect Support Product Page

Delete Image from related record

Asked 16 Aug 2019 11:20:31
1
has this question
16 Aug 2019 11:20:31 Charles Knight posted:
I need some help to try and understand how to delete one image from several images which are related to a single record.

Setup:

I have two tables; machinery and images. Images is related to machinery on a field called machinery_id

So a single record in machinery can have an unlimited number of images associated with it.

On my view edit page for a record in machinery I have a repeat that shows the images associated with that record, underneath I have a delete button which I want to be able to use to delete the single image with.

I have a server action which is set to delete the image but I just can't seem to get it working, I think its to do with not calling the image_id variable correctly but as App Connect is so complicated and there is no mention of this type of deletion in the manual I'm stuck!

Anyone who has done this or can give me some step by step help would be much appreciated

CK

Replies

Replied 16 Aug 2019 12:44:45
16 Aug 2019 12:44:45 Teodor Kuduschiev replied:
Hello Charlie,
Wrap your delete button in a server connect form. Use a hidden field with the file name/path/id or whatever you need to pass to your server action containing the delete file step.
Then in your server action, import this form and the hidden field will appear under POST vars. Use it where you need the file id/path/name and you are done.
Replied 16 Aug 2019 13:39:53
16 Aug 2019 13:39:53 Charles Knight replied:
Thanks Teodor,

Got it working now...

How do I make the delete button refresh the page after its clicked?
Replied 16 Aug 2019 14:24:22
16 Aug 2019 14:24:22 Teodor Kuduschiev replied:
You don't refresh the page after the button is clicked.
As in any other case, you should use the dynamic events of the server connect form (on success) to run the server connect which lists your files on the page.
Replied 16 Aug 2019 14:40:14
16 Aug 2019 14:40:14 Charles Knight replied:
Oh right...

when I try to use a static event on a given element I always et the following error!
www.antinol.com.au/img/dmx-error.jpg

Replied 16 Aug 2019 17:22:29
16 Aug 2019 17:22:29 Teodor Kuduschiev replied:
Dynamic event, Charlie - on the server connect form itself, not a static event applied to the button...
Replied 17 Aug 2019 10:01:28
17 Aug 2019 10:01:28 Charles Knight replied:
so I apply a dynamic event to the form on the page which has the button/submit within it right? Then what, what action do I choose for the dynamic event, I have too many choices and no idea whats expected, I just want the page to reload to show the now deleted image missing but there is no choice for reload - once again I find App Connect confusing and very un-user friendly!
Replied 17 Aug 2019 10:13:00
17 Aug 2019 10:13:00 Charles Knight replied:
I had this from the old server action days:

<a class="btn btn-info" dmx-bind:href="sortable/index.php?int_id={{query.id}}" target="popup"
dmx-on:click="window.open('sortable/index.php?int_id=query.id','popup','width=500,height=800, resizable=yes, scrollbars=yes'); return false;">Set Image Order</a>

I have changed the href to dmx-bind:href and the click to dmx-on:click, these work but how do I get the window.open popup width, height, etc under the new App connect, again there is no logical way I can find to do this!
Replied 17 Aug 2019 10:15:12
17 Aug 2019 10:15:12 Charles Knight replied:
Please also tell me why the Static Event feature keeps coming up with this error:
www.antinol.com.au/img/dmx-error.jpg
Replied 17 Aug 2019 11:03:12
17 Aug 2019 11:03:12 Teodor Kuduschiev replied:
Charlie,
Not sure what you mean by App Connect is not user friendly, in the past few years we received really nice feedback for App Connect and App Connect based plugins.

Once again, you do NOT REFRESH THE PAGE with App Connect .... you just reload the data source returning the records on your page.
You DO NOT USE STATIC EVENTS but DYNAMIC EVENTS!

Select your form, select DYNAMIC EVENTS > ADD NEW > SERVER CONNECT > ONSUCCESS > and select your server connect returning the records on your page, under it you will see LOAD - select it.

On success the form which submitted the delete action will reload the data which returns your records - that's how App Connect works.

Reloading the whole page is really really really old technology. The old, broken, outdated DW Server Behaviors used to work like this and that''s no longer the case.
Replied 19 Aug 2019 15:59:59
19 Aug 2019 15:59:59 Charles Knight replied:
Done that - several times and it DOSEN'T WORK, this is why I find App Connect so hard!!!

<form action="../dmxConnect/api/Interviews/Delete-Image.php" method="post" id="deleteimage" title="deleteimage" is="dmx-serverconnect-form" site="undefined" dmx-on:success="serverconnectdetails.load({id: query.id})">
Replied 20 Aug 2019 07:47:29
20 Aug 2019 07:47:29 Teodor Kuduschiev replied:
Hi Charlie,
I will need a link to your page where i can check what and why is not working.
Replied 20 Aug 2019 10:48:59
20 Aug 2019 10:48:59 Charles Knight replied:
Can I private message you as the page you is password protected?
Replied 20 Aug 2019 12:23:30
20 Aug 2019 12:23:30 Teodor Kuduschiev replied:
Yes, send it to

Reply to this topic