Skip to content

Allow to define a template in action definition - #377

Merged
GSadee merged 1 commit into
Sylius:1.14from
loic425:feature/allow-to-define-template-in-action
May 23, 2025
Merged

Allow to define a template in action definition#377
GSadee merged 1 commit into
Sylius:1.14from
loic425:feature/allow-to-define-template-in-action

Conversation

@loic425

@loic425 loic425 commented May 20, 2025

Copy link
Copy Markdown
Member

Replace #376

final class SubscriptionGrid extends AbstractGrid 
{
    public function buildGrid(GridBuilderInterface $gridBuilder): void
    {
        $gridBuilder
            ->addActionGroup(
                ItemActionGroup::create(
                    Action::create('show', 'custom_show')
                        ->setTemplate('grid/action/show.html.twig')
                    ,
                )
            )
        ;
    }
}           

⚠️ We cannot use this feature in the test application for now, cause the TwigGridRenderer from Resource bundle needs to use this template getter first.

In the package, there are two ways of defining the template.
1/ On Field => within options property
2/ On Filter => directly within template property

Indeed the grid could be used in non-Twig/non-HTML context.
Definining the template in the options could be more detached to "HTML", but I think it's simpler for the DX to define this within a simple setTemplate. For now we use grids within HTML in 100% of the case, and even I already have some PoC to define console operations with grids, this is not bad to keep that getter/setter unused there.

@loic425
loic425 force-pushed the feature/allow-to-define-template-in-action branch 6 times, most recently from 8f89772 to 9134f27 Compare May 20, 2025 07:48

@diimpp diimpp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The long awaited feature 👍 It always felt weird to be forced to define new type just to use alternative template.

@GSadee GSadee added the Feature New feature proposals. label May 23, 2025
@GSadee
GSadee merged commit d9137ca into Sylius:1.14 May 23, 2025
@GSadee

GSadee commented May 23, 2025

Copy link
Copy Markdown
Member

Thank you @loic425! 🎉

@loic425
loic425 deleted the feature/allow-to-define-template-in-action branch May 23, 2025 14:59
NoResponseMate added a commit to Sylius/SyliusResourceBundle that referenced this pull request May 26, 2025
| Q               | A
| --------------- | -----
| Bug fix?        | no
| New feature?    | yes
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | 
| License         | MIT

Related to Sylius/SyliusGridBundle#377
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature New feature proposals.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants