form with confirmation (sometimes)
I have a form to allow deleting some variables. If the deleted item is 'empty' it should be possible to delete it without any problem; but full items should have a 'confirmation' step before deleting them. I have read http://drupal.org/node/387674 and http://drupal.org/node/385640; but in my case I need to pass an array to the confirmation form, and I think it has to be an easier way to allow a "Are you sure you want to do this?". Any hint is welcome. -- *La vida és com una taronja, què esperes a exprimir-la? *Si creus que l'educació és cara, prova la ignorància. *La vida és com una moneda, la pots gastar en el que vulguis però només una vegada. *Abans d'imprimir aquest missatge, pensa en el medi ambient.
Look at node module, specifically node_admin_nodes() and node_admin_nodes_validate() and node_admin_nodes_submit() which are all found in node.admin.inc in Drupal 6. It provides this same functionality - it only shows a confirmation form if the operation is to delete nodes. -Mike On Jun 25, 2009, at 9:29 AM, Lluís wrote:
I have a form to allow deleting some variables. If the deleted item is 'empty' it should be possible to delete it without any problem; but full items should have a 'confirmation' step before deleting them.
I have read http://drupal.org/node/387674 and http://drupal.org/node/385640; but in my case I need to pass an array to the confirmation form, and I think it has to be an easier way to allow a "Are you sure you want to do this?".
Any hint is welcome.
-- *La vida és com una taronja, què esperes a exprimir-la? *Si creus que l'educació és cara, prova la ignorància. *La vida és com una moneda, la pots gastar en el que vulguis però només una vegada. *Abans d'imprimir aquest missatge, pensa en el medi ambient.
__________________ Michael Prasuhn 503.488.5433 office 971.244.2595 cell 503.661.7574 home mike@mikeyp.net http://mikeyp.net
I have taken a look to these funcions but I cannot see how $form_state['rebuild'] = TRUE; make confirmation appear. On Thu, Jun 25, 2009 at 7:13 PM, Michael Prasuhn<mike@mikeyp.net> wrote:
Look at node module, specifically node_admin_nodes() and node_admin_nodes_validate() and node_admin_nodes_submit() which are all found in node.admin.inc in Drupal 6. It provides this same functionality - it only shows a confirmation form if the operation is to delete nodes.
-Mike
On Jun 25, 2009, at 9:29 AM, Lluís wrote:
I have a form to allow deleting some variables. If the deleted item is 'empty' it should be possible to delete it without any problem; but full items should have a 'confirmation' step before deleting them.
I have read http://drupal.org/node/387674 and http://drupal.org/node/385640; but in my case I need to pass an array to the confirmation form, and I think it has to be an easier way to allow a "Are you sure you want to do this?".
Any hint is welcome.
-- *La vida és com una taronja, què esperes a exprimir-la? *Si creus que l'educació és cara, prova la ignorància. *La vida és com una moneda, la pots gastar en el que vulguis però només una vegada. *Abans d'imprimir aquest missatge, pensa en el medi ambient.
__________________ Michael Prasuhn 503.488.5433 office 971.244.2595 cell 503.661.7574 home mike@mikeyp.net http://mikeyp.net
-- *La vida és com una taronja, què esperes a exprimir-la? *Si creus que l'educació és cara, prova la ignorància. *La vida és com una moneda, la pots gastar en el que vulguis però només una vegada. *Abans d'imprimir aquest missatge, pensa en el medi ambient.
The $form_state['rebuild'] forces the form API to rebuild the same form, using the same processing function, but instead of giving a empty $form_state, it gives a full filled array with values you set into. Somehow, in validate then submit, you do a $form_state['delete'] = array(<your nid's here>), then, in you processing form function, you can catch the $form_state if not empty (and filled with your 'delete' attribute), then you can use a if statement to build a different form (in your case, a simple config_form(), with an altered '#submit' which will be the real delete operation submit callback). Hope it helps. Le jeudi 25 juin 2009 à 19:33 +0200, Lluís a écrit :
I have taken a look to these funcions but I cannot see how $form_state['rebuild'] = TRUE; make confirmation appear.
On Thu, Jun 25, 2009 at 7:13 PM, Michael Prasuhn<mike@mikeyp.net> wrote:
Look at node module, specifically node_admin_nodes() and node_admin_nodes_validate() and node_admin_nodes_submit() which are all found in node.admin.inc in Drupal 6. It provides this same functionality - it only shows a confirmation form if the operation is to delete nodes.
-Mike
On Jun 25, 2009, at 9:29 AM, Lluís wrote:
I have a form to allow deleting some variables. If the deleted item is 'empty' it should be possible to delete it without any problem; but full items should have a 'confirmation' step before deleting them.
I have read http://drupal.org/node/387674 and http://drupal.org/node/385640; but in my case I need to pass an array to the confirmation form, and I think it has to be an easier way to allow a "Are you sure you want to do this?".
Any hint is welcome.
-- *La vida és com una taronja, què esperes a exprimir-la? *Si creus que l'educació és cara, prova la ignorància. *La vida és com una moneda, la pots gastar en el que vulguis però només una vegada. *Abans d'imprimir aquest missatge, pensa en el medi ambient.
__________________ Michael Prasuhn 503.488.5433 office 971.244.2595 cell 503.661.7574 home mike@mikeyp.net http://mikeyp.net
BTW, I don't like the node.module implementation of config_form on delete workflow. Even worst in comment.module, they do the same stuff accessible directly to $_POST superglobal. They should properly do this using a multistep form, I.E. by accessing variables in the $form_state and playing with the $form_state['rebuild'] option, which they are not apparently doing. Pierre. Le jeudi 25 juin 2009 à 10:13 -0700, Michael Prasuhn a écrit :
Look at node module, specifically node_admin_nodes() and node_admin_nodes_validate() and node_admin_nodes_submit() which are all found in node.admin.inc in Drupal 6. It provides this same functionality - it only shows a confirmation form if the operation is to delete nodes.
-Mike
On Jun 25, 2009, at 9:29 AM, Lluís wrote:
I have a form to allow deleting some variables. If the deleted item is 'empty' it should be possible to delete it without any problem; but full items should have a 'confirmation' step before deleting them.
I have read http://drupal.org/node/387674 and http://drupal.org/node/385640; but in my case I need to pass an array to the confirmation form, and I think it has to be an easier way to allow a "Are you sure you want to do this?".
Any hint is welcome.
-- *La vida és com una taronja, què esperes a exprimir-la? *Si creus que l'educació és cara, prova la ignorància. *La vida és com una moneda, la pots gastar en el que vulguis però només una vegada. *Abans d'imprimir aquest missatge, pensa en el medi ambient.
__________________ Michael Prasuhn 503.488.5433 office 971.244.2595 cell 503.661.7574 home mike@mikeyp.net http://mikeyp.net
participants (3)
-
Lluís -
Michael Prasuhn -
Pierre Rineau