Skip to content

Commit 86a3915

Browse files
committed
Update button_to() helper to correctly handle the 'data-confirm' option.
1 parent ffbad10 commit 86a3915

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Efficiently/JqueryLaravel/helpers.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ function dom_class($recordOrClass, $prefix = null)
225225
* 'action' - open forms that point to controller actions. E.G. ['action' => 'Controller@method']
226226
* 'method' - HTTP verb. Supported verbs are 'post', 'get', 'delete', 'patch', and 'put'. By default it will be 'post'.
227227
* 'data-remote' - If set to true, will allow the Unobtrusive JavaScript drivers to control the submit behavior. By default this behavior is an ajax submit.
228+
* 'data-confirm' - This will use the unobtrusive JavaScript driver to prompt with the question specified. If the user accepts, the link is processed normally, otherwise no action is taken.
228229
* 'form' - This array will be form attributes
229230
* 'formClass' - This controls the class of the form within which the submit button will be placed. By default it will be 'button_to'.
230231
* @return string
@@ -248,6 +249,9 @@ function button_to($name, array $options = [])
248249
if (array_get($options, 'data-remote')) {
249250
$formOptions['data-remote'] = array_pull($options, 'data-remote');
250251
}
252+
if (array_get($options, 'data-confirm')) {
253+
$formOptions['data-confirm'] = array_pull($options, 'data-confirm');
254+
}
251255
$formOptions = array_merge($formOptions, array_pull($options, 'form', []));
252256

253257
return Form::open($formOptions).'<div>'.Form::submit($name, $options).'</div>'.Form::close();

0 commit comments

Comments
 (0)