Skip to content
Permalink
Browse files

Remove param $confirmMessage.

You can set the confirm message using 'confirm' key in options.
  • Loading branch information...
ADmad committed Jul 5, 2014
1 parent 831b2e9 commit f97ddb13cefa2609210a499c912ed3311ed4f265
Showing with 21 additions and 18 deletions.
  1. +14 −14 src/View/Helper/FormHelper.php
  2. +7 −4 tests/TestCase/View/Helper/FormHelperTest.php
@@ -1416,41 +1416,41 @@ public function postButton($title, $url, array $options = array()) {
}
/**
* Creates an HTML link, but access the URL using the method you specify (defaults to POST).
* Requires javascript to be enabled in browser.
* Creates an HTML link, but access the URL using the method you specify
* (defaults to POST). 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()
* 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
* - `method` - Request method to use. Set to 'delete' to simulate HTTP/1.1 DELETE request. Defaults to 'post'.
* - `confirm` - Can be used instead of $confirmMessage.
* - `method` - Request method to use. Set to 'delete' to simulate
* HTTP/1.1 DELETE request. Defaults to 'post'.
* - `confirm` - Confirm message to show.
* - `block` - Set to true to append form to view block "postLink" or provide
* custom block name.
* - Other options are 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 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 bool|string $confirmMessage JavaScript confirmation message.
* @return string An `<a />` element.
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::postLink
*/
public function postLink($title, $url = null, array $options = array(), $confirmMessage = false) {
$options += array('block' => null);
public function postLink($title, $url = null, array $options = array()) {
$options += array('block' => null, 'confirm' => null);
$requestMethod = 'POST';
if (!empty($options['method'])) {
$requestMethod = strtoupper($options['method']);
unset($options['method']);
}
if (!empty($options['confirm'])) {
$confirmMessage = $options['confirm'];
unset($options['confirm']);
}
$confirmMessage = $options['confirm'];
unset($options['confirm']);
$formName = str_replace('.', '', uniqid('post_', true));
$formOptions = array(
@@ -5356,7 +5356,7 @@ public function testPostLink() {
'/a'
));
$result = $this->Form->postLink('Delete', '/posts/delete/1', array(), 'Confirm?');
$result = $this->Form->postLink('Delete', '/posts/delete/1', array('confirm' => 'Confirm?'));
$this->assertTags($result, array(
'form' => array(
'method' => 'post', 'action' => '/posts/delete/1',
@@ -5369,7 +5369,11 @@ public function testPostLink() {
'/a'
));
$result = $this->Form->postLink('Delete', '/posts/delete/1', array('escape' => false), '\'Confirm\' this "deletion"?');
$result = $this->Form->postLink(
'Delete',
'/posts/delete/1',
array('escape' => false, 'confirm' => '\'Confirm\' this "deletion"?')
);
$this->assertTags($result, array(
'form' => array(
'method' => 'post', 'action' => '/posts/delete/1',
@@ -5401,8 +5405,7 @@ public function testPostLink() {
$result = $this->Form->postLink(
'',
array('controller' => 'items', 'action' => 'delete', 10),
array('class' => 'btn btn-danger', 'escape' => false),
'Confirm thing'
array('class' => 'btn btn-danger', 'escape' => false, 'confirm' => 'Confirm thing')
);
$this->assertTags($result, array(
'form' => array(

0 comments on commit f97ddb1

Please sign in to comment.
You can’t perform that action at this time.