Skip to content

Is it possible show the Relationships\BelongsTo page in Modal when parent resource set protected bool $detailInModal = false; #1484

Answered by lee-to
WillieOng-HK asked this question in Q&A
Discussion options

You must be logged in to vote

There is nothing complicated about it, you can change the preview and display anything! Here is a quick solution that loads a form fragment into a modal

BelongsTo::make(
    __('moonshine::ui.resource.role'),
    'moonshineUserRole',
    formatted: static fn (MoonshineUserRole $model) => $model->name,
    resource: MoonShineUserRoleResource::class,
)->changePreview(function (MoonshineUserRole $value, BelongsTo $field) {
    return ActionButton::make($value->name, $field->getResource()->getFormPageUrl($value->getKey(), fragment: 'crud-form'))
        ->async()
        ->inModal(name: "moonshine-user-edit-{$value->getKey()}");
}),

But this solution will not allow you to reload the table af…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@WillieOng-HK
Comment options

Answer selected by WillieOng-HK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants