What is the benefit when using laravelcollective from and not using HTML

Published 8 months ago by ncrousset

What is the benefit of creating forms with the laravelcollective?

Best Answer (As Selected By ncrousset)
spekkionu

If you don't see a benefit for yourself then you probably don't need it.

I found myself using it less and less and then eventually just stopped pulling it in altogether.

I think Taylor himself must have come to the same conclusion as otherwise it would still be in Laravel core rather than a separate package.

martinbean

@ncrousset A lot less writing of raw HTML.

hendranucleo

@martinbean What about performance? any significant impact with or without?

mtownsend

The biggest reason I use LaravelCollective's HTML package is ease of use. It reduces code writing. For example, I could do:

<form method="post" action="{{ route('users.update', [ 'id' => $user->id ]) }}">
{{ csrf_field() }}

or I could just do

{{ Form::open([ 'method' => 'post', 'route' => [ 'users.update', 'id' => $user->id ] ]) }}

and do the exact same thing.

Alternatively, I find that the Form facade makes select fields so much more painless when you're trying to pre select an option

Ultimately it comes down to personal preference, but I switched to the Form facade specifically for ease of pre selecting select inputs. It really beats writing lots of loops and if statements in your blade syntax.

hendranucleo

@mtownsend This is working for 5.4 ?

ncrousset

5.3 why?

mtownsend

@hendranucleo yes, I'm writing a Laravel 5.4 application using LaravelCollective's Form/Html package.

Swaz
Swaz
8 months ago (41,115 XP)

The biggest draw for me is having my inputs automatically populated with old/existing data with form model binding.

{{ Form::model($user) }}
spekkionu

If you don't see a benefit for yourself then you probably don't need it.

I found myself using it less and less and then eventually just stopped pulling it in altogether.

I think Taylor himself must have come to the same conclusion as otherwise it would still be in Laravel core rather than a separate package.

tekmi
tekmi
3 months ago (108,330 XP)

Every time I started a new project, I've struggled with the same dilemma, so finally I got some time and took a deeper dive look into this package.

I've put all my findings under this blog post: Is it beneficial to add Laravel Collective HTML package into your Laravel project?

Please sign in or create an account to participate in this conversation.