Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.1 - Form: Method number does not exist

I've just upgraded to Laravel 5.1 and i'm creating a simple form with "text" and "number" inputs. My problem came when i need to declare as numeric one of my input fields:

{!! Form::number('otp', null, ['class' => 'form-control', 'placeholder' => 'OTP']) !!}

It outputs this error: Method number does not exist. In addiction, i don't see the section "Html and Forms" in the docs, it seems they removed it.

Does anybody had my same problem with Laravel 5.1?

like image 715
Luca Mormile Avatar asked Nov 20 '25 14:11

Luca Mormile


2 Answers

It seems some rules are changed in 5.1, so to solve this, first update the composer.json:

"require": {
    "laravelcollective/html": "5.1.*"
}

then the app.php file:

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


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

Source: http://laravelcollective.com/docs/5.1/html

like image 62
Luca Mormile Avatar answered Nov 22 '25 05:11

Luca Mormile


You may use {!! Form::input('number', 'otp', null, ['class' => 'form-control']) !!}.

like image 33
Kiran LM Avatar answered Nov 22 '25 06:11

Kiran LM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!