I have a form for creating an organization. If I do not pass the name of the organization through, it fails validation as it should. In the store method I can see the proper errors in $this->validator->getErrors() and I pass those in, but NOTHING shows up in the form. I can dump errors and Input:old() from the view form yet nothing is there. What am I missing?
我有一个创建组织的表单。如果我没有通过组织的名称,它将无法进行验证。在store方法中,我可以在$ 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 个解决方案
#1
0
You need to show us how you are displaying the errors on ther form. Are you using the below to get the errors
您需要向我们展示您如何在表格中显示错误。您是否使用以下内容来获取错误
The errors are in messages.
错误在消息中。
//send this to your view from controller
$messages = $validator->messages();
//retrieve errors in view
foreach ($messages as $message)
{
//
}
#1
0
You need to show us how you are displaying the errors on ther form. Are you using the below to get the errors
您需要向我们展示您如何在表格中显示错误。您是否使用以下内容来获取错误
The errors are in messages.
错误在消息中。
//send this to your view from controller
$messages = $validator->messages();
//retrieve errors in view
foreach ($messages as $message)
{
//
}