kdion4891 / laravel-livewire-forms

A dynamic, responsive Laravel Livewire form component with realtime validation, file uploads, array fields, and more.
243 stars 54 forks source link

there is no way to reset the inputs values ? #17

Open hemant17 opened 4 years ago

hemant17 commented 4 years ago

when users click on save it's should clear the values of input after the summit to DB is that possible?

papalardo commented 4 years ago

Solution:

$ php artisan vendor:publish --tag=form-views
{{-- resources/views/vendor/laravel-livewire-forms/form.blade.php --}}
<div class="row">
    <div class="col-md offset-md-2">
        <button class="btn btn-primary" wire:click="saveAndStay">{{ __('Save') }}</button>
        <button class="btn btn-primary" wire:click="resetForm">{{ __('Reset') }}</button>
        {{-- <button class="btn btn-primary" wire:click="saveAndGoBack">{{ __('Save & Go Back') }}</button> --}}
    </div>
</div>
// FormComponent.php
public function resetForm() 
{
    $this->form_data = [];
}