Form construction

Asked

Viewed 238 times

3

After several months without using Laravel, I now return with this version 5. It may sound silly, but I’m having trouble creating a simple form. Apparently Illumiante/html is not coming by default in the framework, so it is necessary to make some modifications.

I added the following lines to each file:

Composer.json

"illuminate/html": "5.0.*@dev"

config/app.php

'Illuminate\View\ViewServiceProvider',
'Illuminate\Html\HtmlServiceProvider',

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

my view

{{ Form::open(array('action' => 'HomeController@gerarPdf'))}}  
    {{ Form::text('name', 'name') }}  
    {{ Form::password('password') }}  
    {{ Form::submit('Send') }}  
{{ Form::close() }}

Homecontroller

public function gerarPdf() {
    return 'ola mundo';
}

Error message

inserir a descrição da imagem aqui

OBS

I’ve already given Poser update and the method has already been created in the controller.

  • Laravel 5? He’s not in the alpha version?

  • @Wallacemaxters If it is, I don’t know. Through the Composer installation command (provided by the Laravel website) I got the 5th version.

  • The stable version of Laravel is the 5.0.6

  • @luciorubeens Yes, my version is 5.0.6.

2 answers

1


The old Laravel HTML project is now maintained by the group Laravel Collective. I updated some items, starting with Composer.json.

"require": {
    "laravelcollective/html": "~5.0"
}

After executing composer update updated the config/app.php

'providers' => [
    // ...
    'Collective\Html\HtmlServiceProvider',
    // ...
  ],

  'aliases' => [
    // ...
      'Form' => 'Collective\Html\FormFacade',
      'Html' => 'Collective\Html\HtmlFacade',
    // ...
  ],

And the syntax has also been modified.

{!! Form::open(array('action' => 'HomeController@gerarPdf')) !!}
    {!! Form::text('username') !!}
{!! Form::close() !!}

0

It is worth remembering that the illuminate/html continues to exist as a component of the Laravel and works perfectly with the Laravel 5.

Run enter dependency via Poser:

composer require illuminate/html:~5.0

And update the config/app.php

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

'aliases' => [
  // ...
    'Form' => 'Illuminate\Html\FormFacade',
    'Html' => 'Illuminate\Html\HtmlFacade',
  // ...
],

It is worth remembering that these packages did not receive updates in the core of Laravel, and some functionalities may stop working.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.