joe_g Posted August 10, 2020 Posted August 10, 2020 How can i get the label of the repeater matrix entry? I can easily get then type with ->type, but I can't get the label with ->label thanks!
MoritzLost Posted August 10, 2020 Posted August 10, 2020 Not sure if this is documented anywhere, but you can use the RepeaterMatrixPage::matrix() to get the label: // get the label in the current language $page->my_repeater_matrix_field->first()->matrix('label'); In recent versions of RepeaterMatrix, you can also call RepeaterMatrixPage::getMatrixInfo() to get an array of information, including the label: $page->my_repeater_matrix_field->first()->getMatrixInfo(); 6
joe_g Posted August 10, 2020 Author Posted August 10, 2020 perfect, thanks ->matrix('label') worked for me!
DrQuincy Posted Friday at 07:28 AM Posted Friday at 07:28 AM This was just what I needed. Is there a list of other `->matrix()` options anywhere?
dynweb Posted Friday at 09:07 AM Posted Friday at 09:07 AM https://processwire.com/talk/topic/11925-repeater-matrix-intro-and-docs/
Najib Posted 10 hours ago Posted 10 hours ago Hey! Yeah, that's a classic snag with ProcessWire's Repeater Matrix. The ->type property actually returns the "name" (slug) of the type, but ->label isn't a direct property of the item itself. To grab the human-readable label, you have to pull it from the field's definition. You can do it like this: PHP $label = $item->getRepeaterMatrixType()->label; echo $label; Essentially, $item->getRepeaterMatrixType() returns the actual type object, which contains all those extra details like the label, icon, and description. Super handy if you're building out a custom page builder and want the UI to match the backend!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now