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'),
])
useMoonShine\Laravel\Fields\BelongsTo;
useMoonShine\UI\Fields\StackFields;
useMoonShine\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'),
])
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.