Laravel 5.1 one form two submit buttons

后端 未结 1 1707
一生所求
一生所求 2021-02-08 06:02

I am using Laravel 5.1, and I would like to make a form with two submit buttons - Save and Save draft.

But when I post my form I have all the fields except the submit va

1条回答
  •  鱼传尺愫
    2021-02-08 06:46

    you can use the same name and different value attribute for the submit buttons

    // example:

    {!! Form::submit( 'Save', ['class' => 'btn btn-default', 'name' => 'submitbutton', 'value' => 'save'])!!}
    
    {!! Form::submit( 'Save draft', ['class' => 'btn btn-default', 'name' => 'submitbutton', 'value' => 'save-draft']) !!}
    

    // Controller:

    switch($request->submitbutton) {
    
        case 'save': 
            //action save here
        break;
    
        case 'save-draft': 
            //action for save-draft here
        break;
    }
    

    0 讨论(0)
提交回复
热议问题