你會使用類似以下
<?php
function yourmod_menu() {
// for examlple
$items['yourmod/foo/%/delete'] = array(
'title' => 'Delete a foo',
'page callback' => 'drupal_get_form',
'page arguments' => array('youmode_foo_delete_confirm', 2), // 2 is the position of foo_id
'access arguments' => array('delete foo rows'),
'type' => MENU_CALLBACK,
);
return $items;
}
function yourmod_foo_delete_confirm($form, &$form_state, $foo_id) {
// load the row
$foo = yourmod_get_foo($foo_id);
// build your form, if you need to add anything to the confirm form
// ....
// Then use drupal's confirm form
return confirm_form($form,
t('Are you sure you want to delete the foo %title?',
array('%title' => $foo->title)),
'path/to/redirect',
t('Some description.'),
t('Delete'),
t('Cancel'));
}
?>
你可以看看這裏的how core modules do it例子(有看node_delete_confirm)
另請注意,對於Drupal 7,有一個實體系統。所以,如果你的「行」是域的實體,你應該考慮使用實體API,因爲它會輕鬆很多的編碼,特別是具有如果依靠這個模塊http://drupal.org/project/entity – redben 2010-06-13 12:42:47
謝謝,這有助於獲得我在正確的軌道上。 我發現了一個很好的教程在這裏: http://www.akchauhan.com/create-an-action-confirm-form-using-confirm_form-function-in-drupal/ – stotastic 2010-06-13 15:26:45
我發現在這個視頻的真棒例子教程:http://buildamodule.com/video/drupal-7-core-concepts-how-to-add-and-manipulate-pages-with-the-menu-system-how-to-use-placehoders-to- pass-arguments-in-the-middle-of-path – 2011-03-12 18:04:27