1
我想知道如何在表單驗證中包含輔助函數。我是laravel的新手,所以我只對其工作原理有一個基本的瞭解,但我甚至不知道如何包含具有函數的文件,我想用它來驗證表單以進行錯誤檢查。這就是我想用我的所有形式。我怎麼都在全球範圍內此頁面上有形式在刀片模板頁面中包含幫助程序文件
helper.php
<?php
public function hasError($error) {
if(strlen($error) > 0) {
echo "has-error";
}
}
和insdie此頁我用網頁hasError create.blade.php
<div class="form-group <?php hasError($errors->get("keywords")) ?>">
{{ Form::label('keywords', 'Keywords', array('class' => 'col-sm-2 control-label')) }}
<div class="col-sm-10">
{{ Form::text('keywords', NULL, array(
'placeHolder' => 'Keywords',
'class' => 'form-control'
)) }}
謝謝你這麼多爲你我有工作歡呼聲 – ONYX 2014-10-03 22:12:44