Support the ongoing development of Laravel.io →
Views Blade Forms
Last updated 1 year ago.
0

By default in Laravel 5.0, Html and Form are not embedded anymore.

Add the following lines in the require section of composer.json file and run composer update "illuminate/html": "5.*"

Register the service provider in config/app.php by adding the following value into the providers array:

'Illuminate\Html\HtmlServiceProvider'

Register facades by adding these two lines in the aliases array:

'Form'=> 'Illuminate\Html\FormFacade', 'HTML'=> 'Illuminate\Html\HtmlFacade'

Last updated 1 year ago.
0

They are being removed from core in 5 and will need to be added as an optional dependancy in your composer config: https://packagist.org/packages/illuminate/html

Last updated 1 year ago.
0

Thanks, why remove....

Last updated 1 year ago.
0

yuomtheara said:

Thanks, why remove....

+1 why?

Last updated 1 year ago.
0

The reason why it was removed is because it is not a core component. They want to try and keep it as minimal as possible for basic usage and then it is up to the developer to add the modules that he uses. This speeds up laravel and also allows it to be more modular. The reason why people would not use those service providers is because they are using a Javascript framework and nearly all their interaction with the system is with rests calls.

Last updated 1 year ago.
0

I have this in my composer:

"require": {
		"laravel/framework": "~5.0",
		"laravel/elixir": "~1.0",
		"illuminate/html": "5.0.*@dev"
	},

But still cannot use Form::whatever.

My view looks like this:

{{ Form::open(array('action' => 'UsersController@postL')) }}

	{{ Form::text('name', @$name) }}

	{{ Form::password('password') }}

	{{ Form::submit('Send') }}

{{ Form::close() }}

And I get:

Symfony\Component\Debug\Exception\FatalErrorException thrown with message "Call to a member function domain() on a non-object"

Stacktrace:
#1 Symfony\Component\Debug\Exception\FatalErrorException in /Users/petrhomoky/Sites/mailer.dev/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:403
#0 Illuminate\Exception\Handler:handleShutdown in <#unknown>:0

Last updated 1 year ago.
0

Visit here: http://laravel.io/forum/09-01-2014-class-form-not-found And follow usm4n's instructions - just worked for me...

  1. add the following in the require section of the composer.json file and run composer update: "illuminate/html": "4.3.*
  2. add this in providers array of config/app.php file: 'Illuminate\Html\HtmlServiceProvider'
  3. register facades by adding these two lines in the aliases array: 'Form'=> 'Illuminate\Html\FormFacade', 'HTML'=> 'Illuminate\Html\HtmlFacade'
Last updated 1 year ago.
0

ludjer said:

The reason why it was removed is because it is not a core component. They want to try and keep it as minimal as possible for basic usage and then it is up to the developer to add the modules that he uses. This speeds up laravel and also allows it to be more modular. The reason why people would not use those service providers is because they are using a Javascript framework and nearly all their interaction with the system is with rests calls.

So is there a more RESTful way of doing the same thing with Laravel 5?

Last updated 1 year ago.
0

Try to use {!! !!} instead {{ }}

homoky said:

I have this in my composer:

"require": {
  	"laravel/framework": "~5.0",
  	"laravel/elixir": "~1.0",
  	"illuminate/html": "5.0.*@dev"
  },

But still cannot use Form::whatever.

My view looks like this:

{{ Form::open(array('action' => 'UsersController@postL')) }}

  {{ Form::text('name', @$name) }}

  {{ Form::password('password') }}

  {{ Form::submit('Send') }}

{{ Form::close() }}

And I get:

Symfony\Component\Debug\Exception\FatalErrorException thrown with message "Call to a member function domain() on a non-object"

Stacktrace:
#1 Symfony\Component\Debug\Exception\FatalErrorException in /Users/petrhomoky/Sites/mailer.dev/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:403
#0 Illuminate\Exception\Handler:handleShutdown in <#unknown>:0

0

add to your routes.php

Route::post('/users/postL', 'UsersController@postL'); and try {!! Form::open(array('action' => 'UsersController@postL')) !!}

serrati said:

Try to use {!! !!} instead {{ }}

homoky said:

I have this in my composer:

"require": {
 	"laravel/framework": "~5.0",
 	"laravel/elixir": "~1.0",
 	"illuminate/html": "5.0.*@dev"
 },

But still cannot use Form::whatever.

My view looks like this:

{{ Form::open(array('action' => 'UsersController@postL')) }}

 {{ Form::text('name', @$name) }}

 {{ Form::password('password') }}

 {{ Form::submit('Send') }}

{{ Form::close() }}

And I get:

Symfony\Component\Debug\Exception\FatalErrorException thrown with message "Call to a member function domain() on a non-object"

Stacktrace:
#1 Symfony\Component\Debug\Exception\FatalErrorException in /Users/petrhomoky/Sites/mailer.dev/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:403
#0 Illuminate\Exception\Handler:handleShutdown in <#unknown>:0

0

hi homoky

you dont add

'providers' => [
          'Illuminate\Html\HtmlServiceProvider',
       ],

and

'aliases' => [
         'Html'
         'Form'
     ]

you can see this tutorial its very good

https://laracasts.com/series/laravel-5-fundamentals/episodes/10

Last updated 9 years ago.
0

Just for summarize:

Add to composer.json:

	"illuminate/html": "5.*"

Run:

	composer update

Add to the app.php providers array:

	Illuminate\Html\HtmlServiceProvider::class,

Add to the app.php aliases array:

	'Html' 		=> Illuminate\Html\HtmlFacade::class,
	'Form' 		=> Illuminate\Html\FormFacade::class,

Test is out:

	{!! Form::open([]) !!}

	{!! Form::text('name', @$name) !!}

	{!! Form::password('password') !!}

	{!! Form::submit('Send') !!}

	{!! Form::close() !!}

You are done!

Last updated 7 years ago.
0

I started a new Laravel project and then removed the login features with "php artisan fresh".

I followed the above and updated app.php file and composer.json files.

If I add a form using blade syntax, it works just fine.

However when I want to link the Foundation framework by adding {{ HTML::style('css/foundation.min.css') }}
It is printing the link on my home page:

<link media="all" type="text/css" rel="stylesheet" href="http://localhost:8000/css/foundation.min.css">

I checked the debugging tools in Chrome. Nothing is broken. It's finding the style sheet. Why is it printing the html code to my welcome page?

Last updated 8 years ago.
0

@artmonger

In Laravel 5, the Blade tags changed, {{ }} now outputs escaped text, if you want to output raw text, such as HTML - use {!! !!} instead.

0

Ah! That's right.... Thanks, Andrew.

0

Probabily is better the use of Laravel Collective Package: http://laravelcollective.com/

0

AndrewBNZ said:

@artmonger

In Laravel 5, the Blade tags changed, {{ }} now outputs escaped text, if you want to output raw text, such as HTML - use {!! !!} instead.

Yeah Thank's so Much :D

0

this should be noted in the official laravel 5 documentation :)

0

This worked for me.

serrati said:

Try to use {!! !!} instead {{ }}

homoky said:

I have this in my composer:

"require": {
 	"laravel/framework": "~5.0",
 	"laravel/elixir": "~1.0",
 	"illuminate/html": "5.0.*@dev"
 },

But still cannot use Form::whatever.

My view looks like this:

{{ Form::open(array('action' => 'UsersController@postL')) }}

 {{ Form::text('name', @$name) }}

 {{ Form::password('password') }}

 {{ Form::submit('Send') }}

{{ Form::close() }}

And I get:

Symfony\Component\Debug\Exception\FatalErrorException thrown with message "Call to a member function domain() on a non-object"

Stacktrace:
#1 Symfony\Component\Debug\Exception\FatalErrorException in /Users/petrhomoky/Sites/mailer.dev/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:403
#0 Illuminate\Exception\Handler:handleShutdown in <#unknown>:0

Also needed this tweak to make it work.

sineld said:

Just for summarize:

Add to composer.json:

  "illuminate/html": "5.*"

Run:

  composer update

Add to the app.php providers array:

  'Illuminate\Html\HtmlServiceProvider',

Add to the app.php aliases array:

  'Html' 		=> 'Illuminate\Html\HtmlFacade',
  'Form' 		=> 'Illuminate\Html\FormFacade',

Test is out:

  {!! Form::open([]) !!}

  {!! Form::text('name', @$name) !!}

  {!! Form::password('password') !!}

  {!! Form::submit('Send') !!}

  {!! Form::close() !!}

You are done!

Still catching up with L5!

0

Hi, on Laravel 5.1, I use: 'providers' - Illuminate\Html\HtmlServiceProvider::class, 'alias' : 'Form' => Illuminate\Html\FormFacade::class, 'Html' => Illuminate\Html\HtmlFacade::class,

0

Very important thing that is that the facades are case sensitive, so HTML:: is not the same thing as Html::

0

Sometime you use Form or HTML class in your laravel project you will get error like HTML or FORM class not found. You are getting error because Laravel 5 made changes in their library. You should download HTML and FORM class helper using composer.

Add following code in your composer.json file.

"require": {

"laravel/framework": "5.0.*",

"laravelcollective/html": "~5.0"

},

Open config/app.php and add this line to service providers array:

'Collective\Html\HtmlServiceProvider',

Next, add following line of code to aliases array.

'FORM' => 'Collective\Html\FormFacade',

'HTML' => 'Collective\Html\HtmlFacade',

Reference : http://www.expertphp.in/article/html-form-not-found-in-laravel...

Last updated 7 years ago.
0

Don't use illuminate/html use laravelcollective/html. illuminate/html is dead.

If you're using Form or HTML helpers, you will see an error stating class 'Form' not found or class 'Html' not found. The Form and HTML helpers have been deprecated in Laravel 5.0; however, there are community-driven replacements such as those maintained by the Laravel Collective.

For example, you may add "laravelcollective/html": "~5.0" to your composer.json file's require section.

For better security by default, Laravel 5.0 escapes all output from both the {{ }} and {{{ }}} Blade directives. A new {!! !!} directive has been introduced to display raw, unescaped output. The most secure option when upgrading your application is to only use the new {!! !!} directive when you are certain that it is safe to display raw output.

Directly from the Laravel Upgrade Guide for 'to 5.0 from 4.2'

All this stuff is in the upgrade guide.

Last updated 7 years ago.
0

Solution for Laravel 5.3.x

Package illuminate/html is abandoned, you should avoid using it. Use laravelcollective/html instead.

  • Add below code in "require" section of composer.json:
"laravelcollective/html": "~5.0"
  • Run:
composer update
  • Add to the config/app.php providers array:
'Collective\Html\HtmlServiceProvider',
  • Add to the config/app.php aliases array:
'Form' => 'Collective\Html\FormFacade',
'Html' => 'Collective\Html\HtmlFacade',
  • Test is out:
{!! Form::open([]) !!}

{!! Form::text('name', @$name) !!}

{!! Form::password('password') !!}

{!! Form::submit('Send') !!}

{!! Form::close() !!}

You are done!

Last updated 7 years ago.
0

this one works fine

0

Thanks to @tahiryasin for the well thought out explaination.

Had to change this

'Collective\Html\HtmlServiceProvider',

to this

Collective\Html\HtmlServiceProvider::class,

or else I would get

[Symfony\Component\Debug\Exception\FatalThrowableError]   
Undefined constant 'Collective\Html\HtmlServiceProvider'
0

Sign in to participate in this thread!

Eventy

Your banner here too?

yuomtheara yuomtheara Joined 12 Feb 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.

© 2024 Laravel.io - All rights reserved.