I'm creating a web app using laravel 4. I'm having an issue with redirecting back to the previous page with a fragment identifier after a form submission. It just redirects slightly below the top of the page instead of to the specified location. How can I make this work?
here's my html:
<section id="name" class="row">
<div class="large-4 large-centered medium-8 medium-centered columns">
<h3 class="text-center white top-marg-2 bot-marg-2">{{{ trans('header.changeName') }}}</h3>
{{ Form::open(['action' => 'AccountController@changeName']) }}
@include('layout.form.first-name')
@include('layout.form.last-name')
@include('layout.form.submit')
{{ Form::close() }}
</div>
</section>
the included files are my form fields.
This is my get route:
Route::get('account/edit', 'AccountController@getEditProfile');
This is my post route:
Route::post('account/name', 'AccountController@changeName');
This is my controller function:
public function changeName() {
$validator = UserValidate::Name(Input::all());
$firstName = Input::get('first_name');
$lastName = Input::get('last_name');
if ($validator->fails()) {
return Redirect::to("account/edit"."#name")->withErrors($validator)->withInput();
} else {
$user = User::find(Auth::id());
$user->first_name = $firstName;
$user->last_name = $lastName;
$user->save();
return Redirect::to("account/edit"."#name")
->with('success', trans('modals.account5'));
}
}
Any help would be much appreciated.
Thanks