简体   繁体   中英

Lavavel syntax error - unexpected '}'

I'm banging my head against the wall trying to figure this out. I'm trying to load a form in my route in Laravel and I keep getting this error ..

FatalErrorException syntax error, unexpected '}'

// My route...

Route::get('/signup', function()
 {
    {{ Form::open(array('url' => 'foo/bar')) }}
    //
    {{ Form::close() }}
 });

This should work out of the box. Any input would be greatly appreciated.

You are using {{...}} in wrong place, this is Blade template syntax and should not be used in your route's handler, instead create a view file and load that view from your route or from a class , you may try something like this:

Route::get('/signup', function()
{
    return View::make('signup');
});

Next, create a view in your app/views directory and use signup.blade.php as the name, for example:

@extends('layouts.master')
@section('content')
    {{ Form::open(array('url' => 'foo/bar')) }}
        {{ Form::text('username', Input::old('username')) }}
        {{ Form::submit('Submit', array('class' => 'btn btn-primary')) }}
    {{ Form::close() }}
@stop

Make sure you have a views/layouts/master.blade.php file available.

The routes.php file is not a blade templating system so you don't have to add those curly braces to echo your function(s).

Try this:

Route::get('/signup', function()
 {
    Form::open(array('url' => 'foo/bar'));
    //
    Form::close();
 });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM