doumi7861 2014-06-23 12:16
浏览 52
已采纳

laravel在视图中打印一个输入的错误消息

I would like to print the error message for just the value input text field after the page redirecting from the controller.

I tried that

{{Form::text('value', '', array())}}
            <span class="errorMessage">
                <?php
                    echo $errors->first('value');
                ?>
            </span>

but I got empty results though I already redirected the request with the errors like this:

$input = Input::all();
        $validation = Validator::make($input, WaitingTimes::$rules);
        if($validation->passes()){

        }else{
            return Redirect::route('waitingtimes.create')->withInput()->withErrors($validation);
        }

Edit 1

I already tried $errors->has('value') but I also got nothing

Edit 2

public static $rules = array(
        'startTime' => 'required',
        'endTime' => 'required',
        'value' => 'required:integer'
    );

so as you see the value must be integer, but I entered string so there is absoltuly an error

  • 写回答

1条回答 默认 最新

  • douda5706 2014-06-23 12:23
    关注

    This

    'value' => 'required:integer'
    

    Should be:

    'value' => 'required|integer'
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?