简体   繁体   中英

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?

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 .

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

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