Support the ongoing development of Laravel.io →
Blade Forms Architecture

Hey, so what I have is a form that is going to appear on multiple pages for different scenarios, and being sent to different controllers depending on the scenario. I'd like to have just the one blade template with the same form, but I'm wondering what I would specify as the form's action. The only thing that comes to mind is having it sent to a controller or helper class with a parameter that tells it which scenario-specific controller it should be sent to, but from what I gather, controller->controller routing isn't best practise. What can I do to reuse this form?

Last updated 3 years ago.
0

Can't you just create the Form open and Form close for each specific page, and include only the form fields? Something like

{{ Form::open(['route' => 'my.route']) }}
    @include('form_fields')
{{ Form::close() }}
Last updated 3 years ago.
0

Ooo good call, thanks!

Last updated 3 years ago.
0

You can also do

@include('myform', array('var1' => 'value', 'var2' => 'othervalue'));

to send variables to the included file. Then inside that, do

{{ Form::open(['route' => $var1]) }}
Last updated 3 years ago.
0

Or set action from controller.

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Meowts meowts Joined 10 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.