btaylor507
btaylor507

Reputation: 211

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.

Upvotes: 1

Views: 573

Answers (2)

Cosmin.
Cosmin.

Reputation: 1

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();
 });

Upvotes: 0

The Alpha
The Alpha

Reputation: 146191

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.

Upvotes: 4

Related Questions