我已经开始使用 Laravel 4 Beta 2 并且遇到了验证问题。
我有这条路线:
Route::post('inscription', function()
{
$rules = array(
array('nom' => 'required'),
array('passe' => 'required')
);
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails())
{
echo var_dump(Input::all());
$messages = $validator->messages();
print_R($messages->all());
}
});
当我在表单中输入值时,我得到了:
array (size=2)
'nom' => string 'Dupont' (length=6)
'passe' => string 'monpasse' (length=8)
Array ( [0] => The 0 field is required. [1] => The 1 field is required. )
告诉我字段是必需的,但有值!