CarlEOgden's avatar

adding ?tab=xyz to a return view('contact.create',compact('vars'));

Hi

Do you know if it is possible to to add a ?tab=here when using return view command?

return view('contact.create', compact('agency_id','contact_id',));

I'd like to make it in certain circumstances go to a defined tab instead of the details view!

Thanks for any and all help in advance.

Regards Carl.

0 likes
4 replies
Sinnbeck's avatar

You are returning html, not redirecting. You need to add that in the code where you point to this page :) How does the user get here?

CarlEOgden's avatar

Hi

Thanks for that, this is in my ContactController, create routine and then shows the contact blade and all the partials that are included.

On the dashboard, I have an option called "Add contact" and this calls the above from the route:-

In my main.blade.php

@include('partials.route', [
'label'             => 'Add contact',
'icon'              => 'plus',
'link'              => route('contact::create'),
'controller_name'   => 'ContactController',
'controller_action' => 'create'])
Route::get('contact/create', ['as' => 'create', 'uses' => 'ContactController@create']);

The page shown extends the layout and is called "contact\create.blade.php"

Within this page I have and that contains within that for each tab within that page.

Not sure on what I'd need to set in the blade to then move to a tab?

Does this help any?

Regards Carl

Sinnbeck's avatar

I assume you call this 'link' somewhere?

'link'              => route('contact::create', ['tab' => 'xyz']),

This will add `?tab='xyz' to the url

automica's avatar

@carleogden you could do the tab switching by js. pass in a value for tab into the dom and then reference the data attribute with your js to determine what tab you should be on.

$tab = 'description';

return view('contact.create', compact('agency_id','contact_id', 'tab'));
<body data-tab='{{ $tab }}'>
1 like

Please or to participate in this conversation.