Laravel表单没有获取重定向的任何数据(没有错误没有输入)

时间:2014-01-16 16:46:43

标签: php validation laravel-4

我有一个用于创建组织的表单。如果我没有通过组织的名称,它将无法进行验证。在商店方法中,我可以在$ this-> validator-> getErrors()中看到正确的错误,然后我将其传递出来,但是NOTHING会在表单中显示出来。我可以从视图表单中转储错误和输入:old()但是没有任何东西。我错过了什么?

public function create()
{
    $supportedStates = ['' => 'Choose'] + $this->us_states->supportedStates();
    $procedures = $this->procedures->getList();
    $phoneTypes = $this->phone_types->lists('phone_number_type', 'id');
    return View::make('organizations.create', array('supportedStates' => $supportedStates, 'procedures' => $procedures, 'phoneTypes' => $phoneTypes, 'input' => Input::old()));
}

public function store()
{
    $input = Input::all();
    if($this->validator->passes())
    {
        $new_organization = $this->repository->create(['organization_name' => $input['organization_name']]);  
        if($input['logo_url'])
        {
            $new_organization->processImage($input, Request::root());             
        }
        $new_organization->createRelated($input);
        return Redirect::route('/')
            ->with('message', 'Organization Created.');
    }

    return Redirect::route('organizations.create')
        ->withInput()
        ->withErrors($this->validator->getErrors())
        ->with('message', 'There were validation errors.');
}

1 个答案:

答案 0 :(得分:0)

您需要告诉我们您如何在表单上显示错误。 您是否使用以下内容来获取错误

错误在邮件中。

//send this to your view from controller
$messages = $validator->messages();

//retrieve errors in view
foreach ($messages as $message)
{
    //
}