|
|
@@ -1730,6 +1730,7 @@ class FormHelper extends Helper
|
|
|
* ### Options:
|
|
|
*
|
|
|
* - `escape` - HTML entity encode the $title of the button. Defaults to false.
|
|
|
+ * - `confirm` - Confirm message to show. Form execution will only continue if confirmed then.
|
|
|
*
|
|
|
* @param string $title The button's caption. Not automatically HTML encoded
|
|
|
* @param array $options Array of options and HTML attributes.
|
|
|
@@ -1738,9 +1739,15 @@ class FormHelper extends Helper
|
|
|
*/
|
|
|
public function button($title, array $options = [])
|
|
|
{
|
|
|
- $options += ['type' => 'submit', 'escape' => false, 'secure' => false];
|
|
|
+ $options += ['type' => 'submit', 'escape' => false, 'secure' => false, 'confirm' => null];
|
|
|
$options['text'] = $title;
|
|
|
|
|
|
+ $confirmMessage = $options['confirm'];
|
|
|
+ unset($options['confirm']);
|
|
|
+ if ($confirmMessage) {
|
|
|
+ $options['onclick'] = $this->_confirm($confirmMessage, 'return true;', 'return false;', $options);
|
|
|
+ }
|
|
|
+
|
|
|
return $this->widget('button', $options);
|
|
|
}
|
|
|
|
|
|
@@ -1757,6 +1764,7 @@ class FormHelper extends Helper
|
|
|
* HTTP/1.1 DELETE (or others) request. Defaults to 'post'.
|
|
|
* - `form` - Array with any option that FormHelper::create() can take
|
|
|
* - Other options is the same of button method.
|
|
|
+ * - `confirm` - Confirm message to show. Form execution will only continue if confirmed then.
|
|
|
*
|
|
|
* @param string $title The button's caption. Not automatically HTML encoded
|
|
|
* @param string|array $url URL as string or array
|
|
|
@@ -1804,7 +1812,7 @@ class FormHelper extends Helper
|
|
|
* - `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` - Confirm message to show.
|
|
|
+ * - `confirm` - Confirm message to show. Form execution will only continue if confirmed then.
|
|
|
* - `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.
|