Skip to content

Commit

Permalink
Update button_to() helper to correctly handle the 'data-confirm' option.
Browse files Browse the repository at this point in the history
  • Loading branch information
tortuetorche committed Aug 16, 2014
1 parent ffbad10 commit 86a3915
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Efficiently/JqueryLaravel/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ function dom_class($recordOrClass, $prefix = null)
* 'action' - open forms that point to controller actions. E.G. ['action' => 'Controller@method']
* 'method' - HTTP verb. Supported verbs are 'post', 'get', 'delete', 'patch', and 'put'. By default it will be 'post'.
* '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.
* '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.
* 'form' - This array will be form attributes
* 'formClass' - This controls the class of the form within which the submit button will be placed. By default it will be 'button_to'.
* @return string
Expand All @@ -248,6 +249,9 @@ function button_to($name, array $options = [])
if (array_get($options, 'data-remote')) {
$formOptions['data-remote'] = array_pull($options, 'data-remote');
}
if (array_get($options, 'data-confirm')) {
$formOptions['data-confirm'] = array_pull($options, 'data-confirm');
}
$formOptions = array_merge($formOptions, array_pull($options, 'form', []));

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

0 comments on commit 86a3915

Please sign in to comment.