47

Why are the Form and HTML helpers deprecated since Laravel 5? I know I could use something like laravelcollective/html packages. But I was just wondering why Laravel stopped using/devolving the helpers.

halfer
  • 19,824
  • 17
  • 99
  • 186
Dees Oomens
  • 4,554
  • 3
  • 29
  • 61

3 Answers3

76

The answer is simple.

Taylor Otwell decided to remove Form and Html from core components because it's something that should be maintained by the community through packages like https://github.com/LaravelCollective/html. Few other components were removed to keep the framework slim. Not everyone uses Form and HTML , I personally prefer pure HTML.

My Opinion

One of my opinions on this is the issue of performance, If you check Form and HTML classes you will see how forms are actually generated, which involves looping with foreach and other script just to generate simple form which simply doesn't happen when you use your plain HTML in your blade.

Laravel Form & HTML components also have limitations in terms of full customization but when you use plain HTML in your blade you can freely customize the form in anyway you like and any front-end developer can understand it without learning Laravel or Blade.

I actually think Laravel Form & HTML are for lazy developers, my opinion :)

You can do without Form & Html builders completely or you can use available packages

Emeka Mbah
  • 16,745
  • 10
  • 77
  • 96
  • 5
    I also feel the same way, using plain html for forms is fast & simple rather than using complex form helpers just to make things worse. – ankit.json Nov 10 '16 at 15:53
  • 1
    In some cases, there is no elegant solution. Like a `{!! $channel->lang === 'en' ? 'checked="checked"' : '' !!}` – Sasay Jul 10 '17 at 08:13
  • 4
    Why even use Blade? PHP itself is already a templating engine. – Malchesador Jul 24 '17 at 13:42
  • 17
    Well, "for the lazy developer" is a funny argument. Getting things done fast the right way is not a bad thing. You could argue the same way for any framework, template language etc.: Sass, blade, laravel, bootstrap, jquery - you can do great stuff without any of it, it just takes more time and experience to get it right. Web development is a lot about getting things done fast. And that's what frameworks and helpers like this are made for. – Christopher K. Aug 14 '17 at 10:07
  • 2
    Yes all argumens was ok, but in some cases like make a simple select I need to create a function to do that, all cicle and make if for check selected option, That makes me feel bored... – Rubén Ruíz Aug 22 '17 at 20:27
9

They say Laravel developers removed it because they want to keep framework simple. Not all devs use all components, so they can just add modules manually.

A lot of developers were shocked by this decision, because Laravel Collective is really useful and great part of Laravel. I really hope Laravel Collective will be core part of Laravel framework again.

Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279
0

It's late-2021 and having not started a new Laravel project in a while, I've just been trying to decide myself what to do about forms.

I compared the Laravel 8 blade/form docs against Laravel Collective HTML 6.x.

Overall, I think Taylor's decision was the right one; using HTML with Blade is just much cleaner.

The Form:: object feels like an unnecessary level of abstraction. The statements take longer to type, you have to remember the syntax for them, and they immediately put you at a distance mentally from the actual source code of your page.

HTML5 form code is much cleaner than it used to be. The in-browser validation, custom keyboard layout support for email/numbers etc. has made them easier for users. Editing at source is even more useful if you're using Tailwind to add your CSS classes to your elements inline.

Therefore, why not write directly in HTML whenever you have the opportunity? Plus your IDE will thank you for it by colour-coding everything neatly and syntax checking for you. And it keeps your knowledge of HTML current.

Also, as Emeka said in his answer, other non-Laravel developments can look at the code and understand it: they don't need to consult the Laravel Collective docs to check which argument does what.

Which would you rather write? Something like:

echo Form::label('email', 'E-Mail Address', ['class' => 'awesome']);
echo Form::text('email', 'example@gmail.com');

or:

<label>Email address: 
  <input type="email" name="email" value="{{ old('email') }}" class="awesome">
</label>

CSRF support is now a simple matter of adding @csrf, and the Laravel docs cover using the Blade @error directive for inline-error handling. There are plenty of examples online of how people populate/check more complex fields like <select> etc.

William Turrell
  • 3,227
  • 7
  • 39
  • 57
  • Pure HTML is a great way to generate. But, if there is a string that can modify the HTML contents, we need it for that since pure HTML dose not strip the these tags. – Leo S Oct 27 '21 at 07:58