I am using Laravel 4.1.
I am creating an application where a "team" can have multiple "students" associated with it. I am trying to create a form where you can create a team and add multiple students at the same time.
Each student has multiple form fields, IE: first name, last name, email, etc. I have javascript to add new form entries. Form field names are arrays: students[1][first_name], students[1][last_name] and so on, where the index is incremented.
I am able to validate these fields with a simple loop:
foreach(Input::get('students') as $index => $student)
{
$studentValidation[$index] = Validator::make($student, Student::$rules);
if($studentValidation[$index]->fails())
{
$failed = true;
}
}
if($failed)
{
// The following does no work
View::make('team.create')->withErrors($studentValidation)
}
What I would like is for an array of separate errors to be passed to the make function so I can display errors associated with the creation of individual student records by looping through the array of messages.
Is there an obvious way to do this with Laravel 4.1?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community