浏览代码

deleteLink

euromark 13 年之前
父节点
当前提交
c4481108b6
共有 1 个文件被更改,包括 24 次插入0 次删除
  1. 24 0
      View/Helper/FormExtHelper.php

+ 24 - 0
View/Helper/FormExtHelper.php

@@ -33,6 +33,30 @@ class FormExtHelper extends FormHelper { // Maybe FormHelper itself some day?
 		parent::__construct($View, $settings);
 	}
 
+	/**
+	 * Creates an HTML link, but accesses the url using DELETE method.
+	 * Requires javascript to be enabled in browser.
+	 *
+	 * This method creates a `<form>` element. So do not use this method inside an existing form.
+	 * Instead you should add a submit button using FormHelper::submit()
+	 *
+	 * ### Options:
+	 *
+	 * - `data` - Array with key/value to pass in input hidden
+	 * - `confirm` - Can be used instead of $confirmMessage.
+	 * - Other options is the same of HtmlHelper::link() method.
+	 * - The option `onclick` will be replaced.
+	 *
+	 * @param string $title The content to be wrapped by <a> tags.
+	 * @param string|array $url Cake-relative URL or array of URL parameters, or external URL (starts with http://)
+	 * @param array $options Array of HTML attributes.
+	 * @param string $confirmMessage JavaScript confirmation message.
+	 * @return string An `<a />` element.
+	 */
+	public function deleteLink($title, $url = null, $options = array(), $confirmMessage = false) {
+		$options['method'] = 'DELETE';
+		return $this->postLink($title, $url, $options, $confirmMessage);
+	}
 
 	/**
 	 * fix for required adding (only manually)