ferdinandfrank / vue-forms

Set of Vue.js components to submit forms with ajax.
https://ferdinandfrank.github.io/vue-forms/
MIT License
5 stars 0 forks source link

Success Alert and clear inputs. #4

Closed pieinn closed 6 years ago

pieinn commented 6 years ago

Sorry for disturb again, Please advice how to show Success Alert and clear inputs.

All inputs not cleared when submit form

My Controller : return redirect()->back()->withInput();

Thank you for awesome package.

ferdinandfrank commented 6 years ago

To clear the inputs after the form has been successfully submitted, you can simply add the prop clear with the value true to your AjaxFormComponent:

<ajax-form method="post" action="path/to/server" :clear=true>
...
</ajax-form>

To show a success alert message after the request was processed by the server, the server should return a json response like the following:

return response()->json([
    'alert' => [
        'title'   => 'Success',
        'message' => 'The request was successful!'
    ]
]);

You can view the full list of json params for the response here. I will make a better documentation within the next days!

pieinn commented 6 years ago

Thank you very much! Please provide with some samples