Mojtaba Delshad
Mojtaba Delshad

Reputation: 107

Redirect back to a specific tab in Laravel when Validate has error

I have 4 tabs. When the information is updated and there is no error, I can display the same tab after returning. That's how I set the tab:

return redirect(route('frontend.user.account') . '#edit')->with(['tab' => 'edit']);

Now, suppose there's an error in the update. How can I specify my preferred tab, like the above code??

this is update function :

    public function update(UpdateProfileRequest $request)
    {
        $output = $this->userRepository->update(
            $request->user()->id,
            $request->only('first_name', 'last_name', 'email','national_Code','phone_number','mobile_number','state','city','address','postal_code', 'avatar_type', 'avatar_location'),
            $request->has('avatar_location') ? $request->file('avatar_location') : false
        );

        return redirect(route('frontend.user.account') . '#edit')->with(['tab' => 'edit']);

    }

Upvotes: 1

Views: 626

Answers (1)

Christopher Wilbraham
Christopher Wilbraham

Reputation: 151

The solution for us was to add the tab to the form action.

<form ... action="{{ url()->current() }}/tabname

Upvotes: 1

Related Questions