From version 3.9 it is deprecated and will be deleted in version 4.0, use Fieldset
Contains all Basic Methods.
The StackFields
field allows you to group fields when displaying in the preview.
The fields()
method should accept an array of fields to group.
use MoonShine\Laravel\Fields\BelongsTo;
use MoonShine\UI\Fields\StackFields;
use MoonShine\UI\Fields\Text;
StackFields::make('Title')->fields([
Text::make('Title'),
BelongsTo::make('Author', resource: 'name'),
])
namespaces
use MoonShine\Laravel\Fields\BelongsTo;
use MoonShine\UI\Fields\StackFields;
use MoonShine\UI\Fields\Text;
StackFields::make('Title')->fields([
Text::make('Title'),
BelongsTo::make('Author', resource: 'name'),
])
use MoonShine\Laravel\Fields\BelongsTo;
use MoonShine\UI\Fields\StackFields;
use MoonShine\UI\Fields\Text;
StackFields::make('Title')->fields([
Text::make('Title'),
BelongsTo::make('Author', resource: 'name'),
])
namespaces
use MoonShine\Laravel\Fields\BelongsTo;
use MoonShine\UI\Fields\StackFields;
use MoonShine\UI\Fields\Text;
StackFields::make('Title')->fields([
Text::make('Title'),
BelongsTo::make('Author', resource: 'name'),
])
use MoonShine\Laravel\Fields\BelongsTo;
use MoonShine\UI\Fields\StackFields;
use MoonShine\UI\Fields\Text;
StackFields::make('Title')->fields([
Text::make('Title'),
BelongsTo::make('Author', resource: 'name'),
])
You can customize the display for StackFields
using components.
StackFields::make('Title')->fields([
Text::make('Title'),
LineBreak::make(), BelongsTo::make('Author', resource: 'name'),
])
StackFields::make('Title')->fields([
Text::make('Title'),
LineBreak::make(), // adds a line break
BelongsTo::make('Author', resource: 'name'),
])
StackFields::make('Title')->fields([
Text::make('Title'),
LineBreak::make(), // adds a line break
BelongsTo::make('Author', resource: 'name'),
])
StackFields::make('Title')->fields([
Text::make('Title'),
LineBreak::make(), // adds a line break
BelongsTo::make('Author', resource: 'name'),
])
StackFields::make('Title')->fields([
Text::make('Title'),
LineBreak::make(), // adds a line break
BelongsTo::make('Author', resource: 'name'),
])
To change the set of components in StackFields
under certain conditions, you need to pass a condition and sets of components using a callback function.
StackFields::make('Stack')
->fields(
fn(StackFields $ctx) => $ctx->getData()?->getOriginal()->id === 3 ? [
Date::make('Creation date', 'created_at'),
] : [
Date::make('Creation date', 'created_at'),
LineBreak::make(),
Email::make('Email', 'email'),
]
)
StackFields::make('Stack')
->fields(
fn(StackFields $ctx) => $ctx->getData()?->getOriginal()->id === 3 ? [
Date::make('Creation date', 'created_at'),
] : [
Date::make('Creation date', 'created_at'),
LineBreak::make(),
Email::make('Email', 'email'),
]
)
StackFields::make('Stack')
->fields(
fn(StackFields $ctx) => $ctx->getData()?->getOriginal()->id === 3 ? [
Date::make('Creation date', 'created_at'),
] : [
Date::make('Creation date', 'created_at'),
LineBreak::make(),
Email::make('Email', 'email'),
]
)
StackFields::make('Stack')
->fields(
fn(StackFields $ctx) => $ctx->getData()?->getOriginal()->id === 3 ? [
Date::make('Creation date', 'created_at'),
] : [
Date::make('Creation date', 'created_at'),
LineBreak::make(),
Email::make('Email', 'email'),
]
)
StackFields::make('Stack')
->fields(
fn(StackFields $ctx) => $ctx->getData()?->getOriginal()->id === 3 ? [
Date::make('Creation date', 'created_at'),
] : [
Date::make('Creation date', 'created_at'),
LineBreak::make(),
Email::make('Email', 'email'),
]
)