Skip to content

Instantly share code, notes, and snippets.

@ibrasho
Forked from elena-kolevska/Form::delete macro
Last active August 29, 2015 14:05
Show Gist options
  • Save ibrasho/8e1e546e81e7441c06cd to your computer and use it in GitHub Desktop.
Save ibrasho/8e1e546e81e7441c06cd to your computer and use it in GitHub Desktop.
/*
|--------------------------------------------------------------------------
| Delete form macro
|--------------------------------------------------------------------------
|
| This macro creates a form with only a submit button.
| We'll use it to generate forms that will post to a certain url with
| the DELETE method, following REST principles.
|
*/
Form::macro('delete', function ($url, $label = 'Delete', $formAttrs = array(), $buttonAttrs = array()) {
$formAttrs = array_merge(array(
'method' => 'DELETE',
'class' => 'delete-form',
'url' => $url
), $formAttrs);
return Form::open($formAttrs) . Form::submit($label, $buttonAttrs) . Form::close();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment