armincms/nova-tab is a Laravel package for a laravel nova tool..
It currently has 8 GitHub stars and 73.402 downloads on Packagist (latest version 4.0.2).
Install it with composer require armincms/nova-tab.
Discover more Laravel packages by armincms
or browse all Laravel packages to compare alternatives.
Last updated
Field's Grouping by the tab.
composer require armincms/nova-tab
First create your tab like follow.
Tab::make('tab-name', [
'first-group-name' => 'First Group Label',
'second-group-name' => 'Second Group Label',
'fourth-group' => [
// group fields
],
'fifth-group' => function() {
return [
// group fields
];
}
])->fullwidth();
Then, to insert each field into the created tab; pass the name and the group name
into the withTab macro method.for example:
Text::make('Name')->withTab('tab-name', 'first-group-name');
Text::make('Gender')->withTab('tab-name', 'second-group-name');
First create your tab like follow. Then; for define tab field's, you can use the group method.
Tab::make('tab-name', function($tab) {
// pass fields by callback
$tab->group('first-tab-name', function($group) {
return [
// define your tab fields
];
});
// pass fields by array
// active your tab by `active` method
$tab->group('active-tab', [
// define your tab fields
])->active();
// custom label tab
$tab->group('custom-label-tab', function($group) {
// or inside the group
$group->label('My Custom Label');
return [
// define your tab fields
];
})->label('My Custom Label');
// full width tab by call `fullwidth` method
})->fullwidth();
By default we'll active the first tab. if you want customize the active tab,
it's availabe by call the active method on the tab group.
It's possible to customize the tab label's by passing the label string through the
label method on the group.
If you want jsutify the tab for fill screen; you can call fullWidth method on the Tab::class
field and relation-field into the tab.Panel into the tab.tab into the Panel. use Armincms\Tab\Tab;
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return Tab::make('general', function($tab) {
$tab->group('general', [
ID::make()->sortable(),
Select::make('Tag')->options(function() {
return ['*' => 'all'];
})->default('*'),
])->label(__('General'));
$tab->group('SEO', [
Text::make('Title'),
])->active();
$tab->group('Relations', [
MorphToMany::make('Tag'),
])->label('Relations');
})->toArray();
}
use Armincms\Tab\Tab;
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return Tab::make('general', function($tab) {
$tab->group('general', [$this, 'generalFields'])->label(__('General'));
$tab->group('SEO', [
Text::make('Title'),
])->active();
$tab->group('Relations', [
MorphToMany::make('Tag'),
])->label('Relations');
})->fullwidth()->toArray();
}
public function generalFields()
{
return $this->merge([
ID::make()->sortable(),
Select::make('Tag')->options(function() {
return ['*' => 'all'];
})->default('*'),
]);
}
You can add multiple tab into form and detail page.
for this situation; just needs making different name for different tabs.
relation-field in different tabs.it just work with one of them.
use Armincms\Tab\Tab;
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return [
Tab::make('first-tab', function($tab) {
$tab->group('general', [$this, 'generalFields'])->label(__('General'));
$tab->group('SEO', [
Text::make('Title'),
])->active();
$tab->group('Relations', [
MorphToMany::make('Tag'),
])->label('Relations');
}),
Tab::make('second-tab', function($tab) {
$tab->group('general', [
ID::make()->sortable(),
Select::make('Tag')->options(function() {
return ['*' => 'all'];
})->default('*'),
])->label(__('General'));
$tab->group('SEO', [
Text::make('Title'),
])->active();
$tab->group('Relations', [
MorphToMany::make('Category'),
])->label('Relations');
}),
];
}
public function generalFields()
{
return $this->merge([
ID::make()->sortable(),
Select::make('Tag')->options(function() {
return ['*' => 'all'];
})->default('*'),
]);
}
You can add tab into Panel but you never can add Panel into tab.
use Armincms\Tab\Tab;
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return [
new Panel('First Panel', [
Tab::make('general', function($tab) {
$tab->group('general', [
ID::make()->sortable(),
Select::make('Tag')->options(function() {
return ['*' => 'all'];
})->default('*'),
])->label(__('General'));
$tab->group('SEO', [
Text::make('Title'),
])->active();
$tab->group('Relations', [
MorphToMany::make('Tag'),
])->label('Relations');
}),
]),
}
use Armincms\Tab\Tab;
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return [
new Panel('My Panel', [
Tab::make('general', function($tab) {
$tab->group('Author', [
ID::make()->sortable(),
BelogsTo::make('User'),
])->label(__('General'));
$tab->group('Relations', [
MorphToMany::make('Tag'),
])->label('Relations');
}),
])
];
}
If some fields missing in the tab, with macro method withTab you can add the
missed field into the tab. like following example:
Text::make('FieldName')->withTab('tab-name', 'group-name')