[twig-component] How to get block values in PHP #2139
Unanswered
tacman
asked this question in
Questions & Answers
Replies: 1 comment 1 reply
-
I've been trying to figure out the same thing (but for an Alert component). I don't think you can access the twig template in the PHP class because it hasn't been mounted yet.
FYI The block function already has a second argument |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have an accordion component that can receive data as either attributes or blocks. I'm wondering if there's a more elegant way of gettng the block content.
To render, I have to repeat come code:
I'd like to get the value of header and body inside the PHP part of the component. In PreMount, I have access to the data attributes passed in. Is there any way to access the block values in the PHP? Or a more elegant way to do this?
In particular, since the ID is created from the header, if the header comes in as a block I have to create the id in twig, unless I can get the block value some other way.
It'd be cool if the block command could take default if it didn't exist.
Beta Was this translation helpful? Give feedback.
All reactions