diff --git a/cake/console/templates/default/actions/controller_actions.ctp b/cake/console/templates/default/actions/controller_actions.ctp
index 8327cb44a..c5f199100 100644
--- a/cake/console/templates/default/actions/controller_actions.ctp
+++ b/cake/console/templates/default/actions/controller_actions.ctp
@@ -115,6 +115,9 @@
}
public function delete($id = null) {
+ if (!$this->request->is('post')) {
+ throw new MethodNotAllowedException();
+ }
if (!$id) {
$this->Session->setFlash(__('Invalid id for '));
diff --git a/cake/console/templates/default/views/form.ctp b/cake/console/templates/default/views/form.ctp
index 72afa827d..7842e14c0 100644
--- a/cake/console/templates/default/views/form.ctp
+++ b/cake/console/templates/default/views/form.ctp
@@ -47,7 +47,7 @@
- - Html->link(__('Delete'), array('action' => 'delete', \$this->Form->value('{$modelClass}.{$primaryKey}')), null, sprintf(__('Are you sure you want to delete # %s?'), \$this->Form->value('{$modelClass}.{$primaryKey}'))); ?>";?>
+ - Form->postLink(__('Delete'), array('action' => 'delete', \$this->Form->value('{$modelClass}.{$primaryKey}')), null, sprintf(__('Are you sure you want to delete # %s?'), \$this->Form->value('{$modelClass}.{$primaryKey}'))); ?>";?>
- Html->link(__('List " . $pluralHumanName . "'), array('action' => 'index'));?>";?>
\n";
echo "\t\t\tHtml->link(__('View'), array('action' => 'view', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
echo "\t\t\tHtml->link(__('Edit'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
- echo "\t\t\tHtml->link(__('Delete'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?'), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
+ echo "\t\t\tForm->postLink(__('Delete'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?'), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
echo "\t\t\n";
echo "\t\n";
diff --git a/cake/console/templates/default/views/view.ctp b/cake/console/templates/default/views/view.ctp
index 1f6dbd72f..834672068 100644
--- a/cake/console/templates/default/views/view.ctp
+++ b/cake/console/templates/default/views/view.ctp
@@ -46,7 +46,7 @@ foreach ($fields as $field) {
Html->link(__('Edit " . $singularHumanName ."'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> \n";
- echo "\t\t- Html->link(__('Delete " . $singularHumanName . "'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?'), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>
\n";
+ echo "\t\t- Form->postLink(__('Delete " . $singularHumanName . "'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?'), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>
\n";
echo "\t\t- Html->link(__('List " . $pluralHumanName . "'), array('action' => 'index')); ?>
\n";
echo "\t\t- Html->link(__('New " . $singularHumanName . "'), array('action' => 'add')); ?>
\n";
@@ -129,7 +129,7 @@ echo "\t\n";
echo "\t\t\t\tHtml->link(__('View'), array('controller' => '{$details['controller']}', 'action' => 'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t\tHtml->link(__('Edit'), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
- echo "\t\t\t\tHtml->link(__('Delete'), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), null, sprintf(__('Are you sure you want to delete # %s?'), \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
+ echo "\t\t\t\tForm->postLink(__('Delete'), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), null, sprintf(__('Are you sure you want to delete # %s?'), \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t\n";
echo "\t\t\n";
diff --git a/cake/libs/exceptions.php b/cake/libs/exceptions.php
index daa1e7f39..fc153a0fe 100644
--- a/cake/libs/exceptions.php
+++ b/cake/libs/exceptions.php
@@ -99,6 +99,26 @@ class NotFoundException extends RuntimeException {
}
}
+/**
+ * Represents an HTTP 405 error.
+ *
+ * @package cake.libs
+ */
+class MethodNotAllowedException extends RuntimeException {
+/**
+ * Constructor
+ *
+ * @param string $message If no message is given 'Method Not Allowed' will be the message
+ * @param string $code Status code, defaults to 401
+ */
+ public function __construct($message = null, $code = 405) {
+ if (empty($message)) {
+ $message = 'Method Not Allowed';
+ }
+ parent::__construct($message, $code);
+ }
+}
+
/**
* Represents an HTTP 500 error.
*
diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php
index 82353c7d1..d48e0b94e 100644
--- a/cake/libs/view/helpers/form.php
+++ b/cake/libs/view/helpers/form.php
@@ -1268,6 +1268,81 @@ class FormHelper extends AppHelper {
);
}
+/**
+ * Create a `