控制器无法识别视图laravel 4.2中的数据

时间:2016-06-16 03:11:06

标签: laravel laravel-4

嗨所以我有这个功能,用户编辑某个记录。在我看来,我已经填充了它看起来像这样的输入表单 enter image description here

视图后面的

是我的代码

{{ Form::model($list, array('route' =>array('modfyFilesave',$list->subcategoryid , $list->fileid),'method'=>'PUT')) }}
            <h6>Filename    : </h6>
            {{ Form::text('x', $list->filename , array('class' => 'validate')) }}
            <h6>File type   : {{ $list->filetype }} </h6>
            @if($list->filetype == 'ppt' || $list->filetype == 'pptx')
                <img src="{{ asset('img/ico/pptico.PNG') }}" class="imgico">

            @elseif($list->filetype == 'doc' || $list->filetype == 'docx')
                <img src="{{ asset('img/ico/wordico.PNG') }}" class="imgico">

            @elseif($list->filetype == 'pdf')
                <img src="{{ asset('img/ico/pdfico.PNG') }}" class="imgico">

            @elseif($list->filetype == 'xls' || $list->filetype == 'xlsx')
                <img src="{{ asset('img/ico/excelico.PNG') }}" class="imgico">

            @elseif($list->filetype == 'txt')
                <img src="{{ asset('img/ico/txtico.PNG') }}" class="imgico">

            @elseif($list->filetype == 'csv')
                <img src="{{ asset('img/ico/csvico.PNG') }}" class="imgico">
            @endif

            <h6>Size        : {{ $list->filesize }} </h6>
            @if($list->confidential == 'true')
                {{ Form::checkbox('conf', 'true', true , array('id' => 'test5')) }}
                <label for="test5">confidential</label>
            @else
                {{ Form::checkbox('conf', 'true', null , array('id' => 'test5')) }}
                <label for="test5">confidential</label>
            @endif

            {{Form::select('sCategory',[ $list->subcategoryid =>'CURRENT CATEGORY :  ' . $list->subcategoryname . ' | ' . $list->maincategoryname] + $cats )}}

            {{ Form::submit('save', array('class' => 'btn btn-primary defcolor')) }}
        {{ Form::close()}}  

然后接收到它的函数在这里

public function savemodfile($scid , $id)
{
    $rules = array(
        'x' => 'required|min:2|max:250|unique:nsa_fileuploads,filename'
    );

    $messages = array(
        'x.required'    => 'Please provide a filename.',
        'x.min'     => 'Filename should have atleast 2 characters.',
        'x.max'     => 'Filename can only have maximum of 250 characters.',
        'x.unique'  => 'Filename already exist.'
    );

    $validator = Validator::make(Input::all(), $rules , $messages);
    if ($validator->fails()) 
    {
        dd('some errors');
    }
    else
    {
        dd('okay');
    }
}
事实是,在我看来,它总是进入if($validator->fails())甚至是内部,有数据。谁能指出我的错误?还是改进我的代码?非常感谢!

1 个答案:

答案 0 :(得分:1)

尝试转储验证程序返回的错误,给出的消息应该为您提供验证时确切失败的方向。

// dump errors
dd($validator->messages()->toArray());

有关详细信息,请参阅:https://laravel.com/docs/4.2/validation#error-messages-and-views