【问题标题】:error while implementing form in laravel blade template在 laravel 刀片模板中实现表单时出错
【发布时间】:2016-01-30 09:54:34
【问题描述】:

我是 laravel 的新手。我正在尝试在我的 form.blade.php 页面中创建一个基本表单。但是当我尝试导航到我的 form.blade.php 页面时,我收到以下错误:

5fca28a34b9eeee32d99bfd5ad77d6a463cb98c9.php 中的 FatalErrorException 第 23 行:语法错误,意外 'put' (T_STRING),期待 ')'

在我的 route.php 中,我调用 View::make() 方法来访问 form.blade.php 页面

Route::get('/',function(){
   return View::make('form');
});

form.blade.php 页面::

<!DOCTYPE html>
<html>
<body>
   {{Form::open(array('url'=>'thanks'))}}

   {{Form::label('email','Email Address')}}
   {{Form::text('email')}}

    {{Form::label('os','operating system')}}
    {{Form::select('os',array(
                           'linux'=>'Linux',
                           'mac'=>'Mac',
                           'windows'=>'windows'
                           ))}}

    {{Form::label('comment','Comment')}}
    {{From::textarea('comment','',array('placeholder=>'put your comment here'))}}

    {{Form::checkbox('agree','yes',false)}}
    {{Form::label('agree','i agree with your terms and condition')}}

    {{Form::submit('submit')}}
    {{Form::close()}}
</body>
</html>

【问题讨论】:

    标签: php forms laravel


    【解决方案1】:
    {!! Form::open(array('url'=>'thanks')) !!}
    
    {!! Form::label('email','Email Address') !!}
    {!! Form::text('email') !!}
    
    {!! Form::label('os','operating system') !!}
    {!! Form::select('os',array(
                       'linux'=>'Linux',
                       'mac'=>'Mac',
                       'windows'=>'windows'
                       )) !!}
    
    {!! Form::label('comment','Comment') !!}
    {!! Form::textarea('comment','',array('placeholder'=>'put your comment here')) !!}
    
    {!! Form::checkbox('agree','yes',false) !!}
    {!! Form::label('agree','i agree with your terms and condition') !!}
    
    {!! Form::submit('submit') !!}
    {!! Form::close() !!}
    

    以上是form/html的正确使用方式,这里是文档laravelcollective/html

    【讨论】:

      【解决方案2】:
      {{From::textarea('comment','',array('placeholder=>'put your comment here'))}}
      

      应该是

      {{From::textarea('comment','',array('placeholder'=>'put your comment here'))}}
      

      好像你少了一个单引号。

      【讨论】:

      • 谢谢!我已经更正了。现在它说“找不到类表单”错误
      • 你使用的是哪个版本的 laravel?是否包含表单外观?
      • 我使用的是 5.2 版.. 我不确定它是否包含在内
      猜你喜欢
      • 2015-10-24
      • 2015-01-21
      • 2013-04-29
      • 2014-11-08
      • 2013-09-27
      • 2017-07-15
      • 2017-04-03
      • 2018-05-31
      相关资源
      最近更新 更多