我对 Laravel 还很陌生宇宙。
所以我正在关注 OpenClassrooms 上的教程,该教程是关于 Laravel 4 的,而我正在使用 Laravel 5,所以我在尝试调整我的 Controller 并让它们在我的项目中工作时遇到了一些麻烦,并且在摆脱之后关于命名空间依赖项的许多错误,我得到了一个看起来像未处理的文本 html 的表单,以下是显示的内容:
<form method="POST" action="http://gappsl/users" accept-charset="UTF-8">
<input
name="_token"
type="hidden"
value="HMfnLvctXZqOuCpSdeJXML76L2KoPsZtadpIqOnm">
<label for="nom">Enter your name:</label>
<input name="nom" type="text" id="nom">
<input type="submit" value="Submit">
</form>
这是我的 Controller :
<?php namespace App\Http\Controllers; use \View;
class UsersController extends Controller {
public function getInfos() {
return View::make('infos');
}
public function postInfos() {
echo 'The name is ' . Input::get('nom');
}
}
?>
这是我的观点:
@extends('tempform')
@section('content') {{ Form::open(array('url'=>'users')) }} {{ Form::label('nom', 'Enter your name:') }} {{ Form::text('nom') }} {{ Form::submit('Submit') }} {{ Form::close() }}
@stop
<!doctype html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<body>
<p> @yield('content') </p>
</body>
</html>
希望你能帮助我。
最佳答案
在 Laravel 5 中,{{ }}
(例如 {{ Form::open() }}
对 Blade 模板中的变量进行转义。
在 Laravel 5 中,使用 {!!改为 Form::open() !!}
。另外,请仔细检查它是否确实是您正在使用的 Blade 模板(而不是直接的 PHP 模板)。
关于php - 表单在 Laravel 5 中显示为纯文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28747272/