Will
Will

Reputation: 681

Why the laravel4 Form can not be created?

I have a laravel 4 project, and i am going to create a register page. Below is the code of register page.

<!DOCTYPE html>

<html>
    <head>
        <meta charset="UTF-8">
    </head>

    <body>
        {{ Form::open(array('route' => 'user.store')) }}
        <h3>Register</h3>
        <input type="text" name="name" placeholder="enter the username" required><br>
        <input type="password" name="password" placeholder="password" required><br>
        <button type="submit">Regesiter</button>
        {{ Form:: close() }}
    </body>
</html>

when i go to this register page, it shows

{{ Form::open(array('route' => 'user.store')) }}
Register
the box of name input
the box of password input
Register {{ Form:: close() }}

{{ Form::open(array('route' => 'user.store')) }}, and {{ Form:: close() }} shows as strings on the page. why does this happen?

Upvotes: 0

Views: 38

Answers (2)

gthuo
gthuo

Reputation: 2566

To use Laravel Blade templating eg the {{}}, your view must be saved with blade. So, if the code appears as strings, probably you have not saved your page as blade, and therefore it displays the code "literally" ie as it is. To save view as blade you use pagename.blade.php eg your viewcan be register.blade.php.
NOTE: When you are "making" the view ie returning it from your controller probably, you dont need to include the .blade part, so it can probably be return View::make('users.register') if your register.blade.php is stored as Views/users/register.blade.php.

Upvotes: 2

Marwelln
Marwelln

Reputation: 29423

When you want to use Blade templating, your files needs to end with .blade.php. Your file is probably just ending with .php.

Upvotes: 1

Related Questions