Hello, I am busy creating a step by step application where the user have to submit stuff.
In the first step the user fills in 2 input fields. After this the user goes to the next page ( step 2 ) and adds a few more stuff into a form and the previous 2 fields are now in a hidden input field ( this is necessary to provide the JS part to run some code ) and there has been some Javascript stuff going on to calculate stuff and print this on the screen.
Now when a users fills in the blank remaining forms in step 2 and submits, I want the user to redirect back to page 2 if the field validation fails.
Somehow Laravel can't handle this and throws a error like undefined index (variable name)
<?php echo e($order['start']); ?>
Those variables are the ones filled in the first step. How can I possibly return to step 2 without getting this error? here is my code.
public function getIndex() {
$input = Input::all();
Session::put('order', $input);
$value = Session::get('order');
return View::make('site.order-summary')->with('order', $value);
}
public function postOrderConfirm() {
$data = Input::all();
$value = Session::get('order');
$validator = Validator::make($data, self::$rules);
if($validator->passes())
{
// do stuff
}
else
{
return Redirect::back()->withInput()->with('order', $value);
}
}
the first method is called after the first step and the second after the 2nd step. the routes look like this
Route::any('order/summary', 'ReservationController@getIndex');
Route::post('order/confirm', 'ReservationController@postOrderConfirm');
And this is how the input fields with the variables causing the errors look like
<input type="hidden" id="start" name="start" value="{{{ $order['start'] }}}"/>
<input type="hidden" id="end" name="end" value="{{{ $order['end'] }}}" />
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community