How can I force a modal to a view when a view page exists.

Hi, I have an action that links to a view page, but I'd also like to have a link to a preview page of that view page as a modal. I am using the following code:
ActionGroup::make([
ViewAction::make()
->slideOver()
->modalHeading('Lorem ipsum dolor sit amet, consectetur adipiscing elit.')
->modalDescription('Aenean mollis elit eget ullamcorper venenatis.')
->label('Preview')
->icon(''),
ViewAction::make()
->label('Full View')
->icon(''),
]),
ActionGroup::make([
ViewAction::make()
->slideOver()
->modalHeading('Lorem ipsum dolor sit amet, consectetur adipiscing elit.')
->modalDescription('Aenean mollis elit eget ullamcorper venenatis.')
->label('Preview')
->icon(''),
ViewAction::make()
->label('Full View')
->icon(''),
]),
The second View action works perfectly and links to the view page. But the first View action does not act as a modal and instead links directly to the view page. How can I get the preview link to work as a modal?
Solution:
As soon as you have a dedicated page, the ViewAction is configured to link to the page. You need something like this: ```php Action::make('preview')...
Jump to solution
3 Replies
Dennis Koch
Dennis Koch3mo ago
Don't use multiple ViewActions. Your custom action should just be a normal Action. Actions need unique names and you are defining view 2 times currently
BuddhaNature
BuddhaNature3mo ago
Thanks, @Dennis Koch , I tried this:
ViewAction::make('preview')
->label('Preview')
->slideOver(),
Action::make('full-report')
->label('Full View')
->url(fn ($record) => BoookResource::getUrl('view', [$record])),
ViewAction::make('preview')
->label('Preview')
->slideOver(),
Action::make('full-report')
->label('Full View')
->url(fn ($record) => BoookResource::getUrl('view', [$record])),
I also tried this:
ViewAction::make('preview')
->label('Preview')
->slideOver(),
ViewAction::make('preview')
->label('Preview')
->slideOver(),
What I'm trying to do is generate an infolist as a slide over modal without losing having a dedicated view page that can be directly linked to.
Solution
Dennis Koch
Dennis Koch3mo ago
As soon as you have a dedicated page, the ViewAction is configured to link to the page. You need something like this:
Action::make('preview')
->infolist(YourResource::infolist(new Infolist))
->slideover()
Action::make('preview')
->infolist(YourResource::infolist(new Infolist))
->slideover()