我在Laravel 5.1中构建了一个控制面板,并且今天刚刚建立了用户管理部分。
当我使用Form::
命令时,似乎会发生这种情况。
我怀疑这是因为登录和注册表格很好,而且这些表格来自Auth Scaffolding,因此表格是用HTML写的,而不是使用Form::
命令。
但是,我使用Form::
命令构建的所有表单都只是将表单代码显示为页面上的文本。
例如:
<h1><i class='glyphicon glyphicon-user'></i> Add User</h1>
{{ Form::open(['role' => 'form', 'url' => '/user']) }}
<div class='form-group'>
{{ Form::label('name', 'Name') }}
{{ Form::text('name', null, ['placeholder' => 'Name', 'class' => 'form-control']) }}
</div>
<div class='form-group'>
{{ Form::label('username', 'Username') }}
{{ Form::text('username', null, ['placeholder' => 'Username', 'class' => 'form-control']) }}
</div>
<div class='form-group'>
{{ Form::label('email', 'Email') }}
{{ Form::email('email', null, ['placeholder' => 'Email', 'class' => 'form-control']) }}
</div>
<div class='form-group'>
{{ Form::label('password', 'Password') }}
{{ Form::password('password', ['placeholder' => 'Password', 'class' => 'form-control']) }}
</div>
<div class='form-group'>
{{ Form::label('password_confirmation', 'Confirm Password') }}
{{ Form::password('password_confirmation', ['placeholder' => 'Confirm Password', 'class' => 'form-control']) }}
</div>
<div class='form-group'>
{{ Form::submit('Create', ['class' => 'btn btn-primary']) }}
</div>
{{ Form::close() }}
以明文形式显示在页面上:
<form method="POST" action="http://localhost/UCP/public/user" accept-charset="UTF-8" role="form"><input name="_token" type="hidden" value="nlVw9OY28DdLUZKOFcrRnlsc79k0LGOGTfURhhFI">
<label for="name">Name</label> <input placeholder="Name" class="form-control" name="name" type="text" id="name">
<label for="username">Username</label> <input placeholder="Username" class="form-control" name="username" type="text" id="username">
<label for="email">Email</label> <input placeholder="Email" class="form-control" name="email" type="email" id="email">
<label for="password">Password</label> <input placeholder="Password" class="form-control" name="password" type="password" value="" id="password">
<label for="password_confirmation">Confirm Password</label> <input placeholder="Confirm Password" class="form-control" name="password_confirmation" type="password" value="" id="password_confirmation">
<input class="btn btn-primary" type="submit" value="Create">
</form>
有人可以帮我将这些显示为表格而不是页面上的文字吗?
答案 0 :(得分:1)
感谢Quasdunk的评论我解决了它,因为它正常工作它需要转义。
以下代码现在可以使用:
<h1><i class='glyphicon glyphicon-user'></i> Add User</h1>
{!! Form::open(['role' => 'form', 'url' => '/user']) !!}
<div class='form-group'>
{!! Form::label('name', 'Name') !!}
{!! Form::text('name', null, ['placeholder' => 'Name', 'class' => 'form-control']) !!}
</div>
<div class='form-group'>
{!! Form::label('username', 'Username') !!}
{!! Form::text('username', null, ['placeholder' => 'Username', 'class' => 'form-control']) !!}
</div>
<div class='form-group'>
{!! Form::label('email', 'Email') !!}
{!! Form::email('email', null, ['placeholder' => 'Email', 'class' => 'form-control']) !!}
</div>
<div class='form-group'>
{!! Form::label('password', 'Password') !!}
{!! Form::password('password', ['placeholder' => 'Password', 'class' => 'form-control']) !!}
</div>
<div class='form-group'>
{!! Form::label('password_confirmation', 'Confirm Password') !!}
{!! Form::password('password_confirmation', ['placeholder' => 'Confirm Password', 'class' => 'form-control']) !!}
</div>
<div class='form-group'>
{!! Form::submit('Create', ['class' => 'btn btn-primary']) !!}
</div>
{!! Form::close() !!}
答案 1 :(得分:0)
只需将刀片模板语法{{ Form::blah() }}
更改为{!! Form::blah() !!}
即可。