1
dongbeta 2014-03-18 16:05:15 +08:00
可以写两个:
'salary' => 'required|numeric|min:3000|max:5000', |
2
yakczh OP @dongbeta 再问个问题, artisan 能把代码里的print_r信息显示在控制台上吗?
Route::post('register', array('before' => 'csrf', function() { $rules = array( 'username' => array('required', 'unique:users,username'), 'email' => array('required', 'email', 'unique:users,email'), 'password' => array('required', 'min:7') ); $data=Input::all(); print_r($data); $validation = Validator::make( $data, $rules); if ($validation->fails()) { $messages = $validator->messages(); print_r($messages); return Redirect::to('/add')->withErrors($validator)->withInput(); }else { User::create($data); } 模板文件是 <h2>Register!</h2> @if( $errors->count() > 0 ) <p>The following errors have occurred:</p> <ul id="form-errors"> {{ $errors->first('email', '<li>:message</li>') }} {{ $errors->first('username', '<li>:message</li>') }} {{ $errors->first('password', '<li>:message</li>') }} </ul> @endif <hr/> {{ Form::open(['register', 'post']) }} <br/>{{ Form::label('username', 'Username') . Form::text('username', Input::old('username')) }} <br>{{ Form::label('email', 'E-mail') . Form::text('email', Input::old('email')) }} <br>{{ Form::label('password', 'Password') . Form::password('password') }} <br>{{ Form::submit('Register!') }} {{ Form::token() . Form::close() }} 递交表单老是重定向到 表单页面,显示 The following errors have occurred: 但是下面什么也没有,怎么在服务端 查看post提交的数据和出错信息? |
3
dongbeta 2014-03-18 16:21:39 +08:00
没看明白。以上这段程序的 php 不应该在一个文件中吧。
|
5
Yuansir 2014-03-18 17:16:34 +08:00
'salary' => 'required|numeric|between:3000,5000,
|