We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Phalcon PHP post link with JavaScript confirmation dialog

I am developing a CRUD system in Phalcon PHP (version 1.3.4).

My goal is to create a link (delete row), that asks for confirmation on click (JavaScript confirmation box) and then goes (request type POST) to the link.

So lets say a user clicks on the "delete row" button.

JavaScript confirmation "Are you sure you want to delete this row?" User clicks "yes" Webpage does a POST to "/users/delete/1" I know CakePHP has a function (FormHelper::postLink()) that does exactly that.

I was wondering if Phalcon PHP also had a function like this.

This looks kind of spammy.

edited Nov '20

Phalcon, first of all, is an skeleton framework... So this specific feature isn't implemented inside it.

For your case, you can have x2 options to do:
1) Create POST route /delete and call it via AJAX request inside your javascript logic (jquery example: $.post('/delete/1', function() {modal.close()}))

2) Inside your modal, create form with <form action="/delete/1" method="post"> and the submit button with "Delete" label and during the click on it - submit the form.