This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I'm still pretty new at this, so bear with me. I'm trying to create a Booking plugin, I can create a 'booking' from the front-end and list all or one booking. What I am having trouble with is figuring out how to delete a booking from the front-end list. I know how to delete a booking, but what I can't figure out is how to get the ID of the booking I want to delete dynamically.
Got it working with the JavaScript API request method, using the data argument. Seems obvious now that I'm thinking of it.
onsubmit="$(this).request('onDelete', { confirm: 'Are you sure?', data: {var: '{{ record.id }}'} }); return false;"
Last updated
Good for you to figure out a way to delete the record. Here is something I would think about as well.
Is this button available to the public? So anyone can delete a record? Or only specific people. I ask this because you can in the browser inspector change the {{ record.id }}
. So if you use auto increment record id's like 1 -> 2 -> 3 then someone could change the number to something different and delete whatever that is.
So make sure you are validating the deletion in some way in your component. That this record does belong to the user or to the shopping cart.
That's a good point I haven't even thought about. For now it's just for me, just trying to learn at the moment before anything.
1-4 of 4