Laravel 5 Tutorial - How to solved Html and Form class not found in Laravel 5.3? to add class HTML & FORM in Laravel 5.3 you need three simple steps. that because By default in Laravel 5.3, Html and Form are not embedded anymore.
at the previews lessons, we have learn about Http Session Method in Laravel 5.3 and How to Create localization for Multiple languages in laravel 5.3.
HTML & Form Class Installation
Add the following lines laravelcollective/html": "5.3.* in the require section of your composer.json file and run composer update.
"require": {
. . . .
"laravelcollective/html": "5.3.*"
. . . .
}
than RUN "compser update" on your terminal.
composer update
Next, we need to Register the service provider by default stored on config/app.php by adding the following value into the providers array:
'providers' => [
// ...
Collective\Html\HtmlServiceProvider::class,
// ...
],
Register facades by adding these two lines in the aliases array on config/app.php :
'aliases' => [
// ...
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
// ...
],
Now, you can add Form and Html class in your Laravel project.
Create Form & HTML Class Example
First, create new Views file stored in resources\views\newformpage.blade.phpnewformpage.blade.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>FORM & HTML</title>
</head>
<body>
<?php
echo Form::open(['url' => 'foo/bar']);
echo Form::text('username','username');
echo '<br/>';
echo Form::text('email','yourmail@here.com');
echo '<br/>';
echo Form::password('password');
echo '<br/>';
echo Form::checkbox('name','value');
echo '<br/>';
echo Form::radio('name','value');
echo '<br/>';
echo Form::file('image');
echo '<br/>';
echo Form::select('Gender',['P'=>'perempuan','L'=> 'Laki-laki']);
echo '<br/>';
echo Form::submit('Register Now');
echo Form::close(); ?>
</body>
</html>
Create new routes on routes\web.php
web.php
Route::get('/form', function () {
return view('newformpage');
});
Now, try to access your new page by following this url : http://localhost:8080/form
Video tutorial Forms & HTML Class in laravel 5.3
See you next Lessons More method can use in Form & Html Class
Không có nhận xét nào:
Đăng nhận xét