[英]Laravel 4 Redirect with fragment url not working
我正在使用laravel 4创建一个Web应用程序。提交表单后,我使用片段标识符重定向回上一页时遇到问题。 它只是重定向到页面顶部下方,而不是重定向到指定位置。 我该如何进行这项工作?
这是我的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>
包含的文件是我的表单字段。
这是我的路线:
Route::get('account/edit', 'AccountController@getEditProfile');
这是我的张贴路线:
Route::post('account/name', 'AccountController@changeName');
这是我的控制器功能:
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'));
}
}
任何帮助将非常感激。
谢谢
事实证明,我已经在页面上两个不同表单上的两个表单域上设置了“自动对焦”。 那是问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.