Skip to content

Instantly share code, notes, and snippets.

@mikegrungey
Forked from elena-kolevska/Form::delete macro
Created July 10, 2014 18:23
Show Gist options
  • Save mikegrungey/89fe62d36621ab75a75d to your computer and use it in GitHub Desktop.
Save mikegrungey/89fe62d36621ab75a75d to your computer and use it in GitHub Desktop.

Revisions

  1. @elena-kolevska elena-kolevska renamed this gist Jan 8, 2014. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion Form::delete → Form::delete macro
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    /*
    |--------------------------------------------------------------------------
    | Delete form macro
  2. @elena-kolevska elena-kolevska created this gist Jan 8, 2014.
    28 changes: 28 additions & 0 deletions Form::delete
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@

    /*
    |--------------------------------------------------------------------------
    | 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, $button_label='Delete',$form_parameters = array(),$button_options=array()){

    if(empty($form_parameters)){
    $form_parameters = array(
    'method'=>'DELETE',
    'class' =>'delete-form',
    'url' =>$url
    );
    }else{
    $form_parameters['url'] = $url;
    $form_parameters['method'] = 'DELETE';
    };

    return Form::open($form_parameters)
    . Form::submit($button_label, $button_options)
    . Form::close();
    });