在Laravel刀片模板中添加图像输入元素

时间:2016-02-08 09:37:08

标签: laravel blade

我想使用以下行的laravel Blade Template中的输入标签上传图像。

{{ Form::image('blog/images/search_btn.gif', 'button_search', ['class' => 'button_search']) }}

但它在视图页面中不断显示错误

  

语法错误,意外情况'内容' (T_STRING),期待']'

这是我的查看页面代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>@yield('title')</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
{!!Html::style('blog/style.css')!!}
{!!Html::style('blog/js/cufon-yui.js')!!}
{!!Html::script('blog/js/arial.js')!!}
{!!Html::script('blog/js/cuf_run.js')!!}

</head>
<body>
<div class="main">
  <div class="header">
    <div class="header_resize">
      <div class="menu_nav"> 
        <ul>
          <li><a href="index.html">Home</a></li>
          <li><a href="support.html">Support</a></li>
          <li class="active"><a href="about.html">About Us</a></li>
          <li><a href="blog.html">Blog</a></li>
          <li><a href="contact.html">Contact Us</a></li>
        </ul>
        <div class="clr"></div>
      </div>
      <div class="searchform">
        <form id="formsearch" name="formsearch" method="post" action="#">

           {{ Form::image('blog/images/search_btn.gif', 'button_search', ['class' => 'button_search']) }}
          <!--   {!! Html::image('blog/images/search_btn.gif', 'alt', array( 'class' => 'button_search' )) !!} 
           {{ Form::image('blog/images/search_btn.gif', 'button_search', ['class' => 'button_search]) }}
          <input name="button_search" src="images/search_btn.gif" class="button_search" type="image" />-->

          <span>
          <input name="editbox_search" class="editbox_search" id="editbox_search" maxlength="80" value="Search" type="text" />
          </span>
        </form>
      </div>
      <div class="clr"></div>
      <div class="logo">
        <h1><a href="index.html">EnergyBox<br />
          <small>put your slogan here</small></a></h1>
      </div>
    </div>
  </div>
</div>
<div class="content">
  @yield('content')
  </div>
<div class="footer">
    <div class="footer_resize">
      <p class="lf">&copy; Copyright MyWebSite. Designed by Blue <a href="http://www.bluewebtemplates.com/">Website Templates</a></p>
      <ul class="fmenu">
        <li><a href="index.html">Home</a></li>
        <li><a href="support.html">Support</a></li>
        <li><a href="blog.html">Blog</a></li>
        <li class="active"><a href="about.html">About Us</a></li>
        <li><a href="contact.html">Contacts</a></li>
      </ul>
      <div class="clr"></div>
    </div>
  </div>
<div align=center>This template  downloaded form <a href='http://all-free-download.com/free-website-templates/'>free website templates</a></div>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

您在第31行错过了结束'

{{ Form::image('blog/images/search_btn.gif', 'button_search', ['class' => 'button_search]) }}

应该是:

{{ Form::image('blog/images/search_btn.gif', 'button_search', ['class' => 'button_search']) }}

此外,如果您正在使用Blade,请使用Blade的注释语法而不是HTML:

<!-- This is a HTML comment -->

{{-- This is a Blade comment, any blade code within this comment won't be parsed. --}}