I am from ASP.NET background. There we used to create form in master page then in every child page we have to create only required fields of the particular page. We do not have to mention action tag in the form for this. The form is submitted by calling the controller class from the code behind page of the child aspx page for the asp button control. So we don't have to create form tag in every page.
Here in laravel, can I do the same thing? I searched in internet but can not found whether it can be done or not? If it can be done in Laravel too, how can I do it? Thank You!!!
@lostdreamer_nl thank you for the response.
I've created the view page keeping form tag in master page. But I want to know how can I post the data to the database using this concept. Since in master page we can not keep action tag. Thank You!!!
without an action="url-here" the form will always post back to it's own URL.
So the only thing to do is make sure that the GET on that URL will show the form, and the POST will handle it.
When you need to update, you can use an extra formfield:
<input name="_method" type="hidden" value="PUT">
this way you can use the same route, but with put / delete / patch.
@extends('master')
@section('form')
@component('cp.form')
@slot('form_action', route('route_name'))
@slot('method', 'PATCH')
@slot('input_name', 'user_name')
if you want use $slot, put the code here
@endcomponent
@endsection