#Insert to table on button click

8 messages · Page 1 of 1 (latest)

orchid valley
#

You should clarify a bit more what you're looking to do, and maybe share code of what you've tried so far. Generally your button is in a form and submits the form to a controller to insert the data in the form and this adds the record. If you mean you want to do it without a page reload, look into livewire perhaps.

coarse radish
orchid valley
#
#My blade file
<form method="POST" action="{{ route('my-route.store') }}">
@csrf
   #My fields
   <button type="submit">
     {{ __('Submit') }}
   </button>
</form>

#my Web.php routes file
Route::post('my-route', [ExampleController::class, 'store'])->name('my-route.store');

#my ExampleController store method
public function store(Request $request)
{
   //Logic to store data from $request->fieldName here and return redirect
}
#

Is that what you're looking for?

coarse radish
#

@orchid valley watching the video rn

coarse radish
#

Thanks a lot @orchid valley !!

orchid valley
#

You were able to get it working?