Why my form open not working in laravel 5.1?

- 1 answer

Ad

Hi all I have problame with my form I am writing html form but its error and this is my route code

Route::get('course','[email protected]');

and this is my CourseController:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class CourseController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('course.create');
    }

and this is my view course/create.blade.php

<!DOCTYPE html>
<html>
<head>
    <title>Hello World</title>
    <link rel="stylesheet" type="text/css" target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" href="">
</head>
<body>
<div class="container">
    {!! Form::open(array('route' => 'course.store')) !!}

        <input type="text"><br>
        <input type="password"><br>
    {!! Form::close() !!}
</div>
</body>
</html>

and error:

Whoops, looks like something went wrong.
1/1 FatalErrorException in 818f720d4e075893d8198d2b0ff02e25 line 9: Class 'Form' not found 

Help me please

Ad

Answer

Ad

With Laravel 5.* the Form & Html have been deprecated. Check out uprade guide (search Form & HTML Helpers).

1. Install laravelcollective/html

composer require laravelcollective/html

2. Add the Form and HTML facades and service provider.

Edit config/app.php and add this line to the 'providers' array:

'Collective\Html\HtmlServiceProvider',

Next, add these lines to the 'aliases' array:

'Form' => 'Collective\Html\FormFacade',
'Html' => 'Collective\Html\HtmlFacade',
Ad
source: stackoverflow.com
Ad