Skip to main content
Tutorial Free

Building a Laravel form without Illuminate/html

October 29, 2015
2 min read
Laravel 5 version got us confused by separating our beloved Form::open world into a separate package. Now you have to add "illuminate/html": "~5.0" to your projects, whenever you want to use forms, right? Not necessary, you can survive without it. How we would build a simple form with that package:
{!! Form::open(array('url' => 'admin/cities')) !!}
  City name:
  
{!! Form::text('title', old('title')) !!}
{!! Form::submit('Save') !!} {!! Form::close() !!}
Now, how it looks if we build it in plain Laravel/HTML:
{{ csrf_field() }} City name:

It's not that bad, is it? The only thing we need to take differently is take care of CSRF protection, which is basically done with method csrf_field(). Another example would be a DELETE form - here we need to use two additional methods.
{{ csrf_field() }} {{ method_field('DELETE') }}
As you can see, function method_field() is used for adding a hidden field like this:

Then Laravel mechanism would point that form to the correct Controller method delete(). So, the question remains open: do we really need that external illuminate/html Form functionality? Not always. Probably, depends on your skills - which would give you faster results - and on your particular usage in your application. Which one do you prefer? Do yo use that package? Tell your experience in comments.

Enjoyed This Tutorial?

Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.

Comments & Discussion

No comments yet…

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.