froot Posted August 7, 2024 Share Posted August 7, 2024 Hello Processwirers, I'm trying to access a field's label in the current user language: $this->template->fields->skills->label // returns either "skills" or "Kenntnisse" depending on the language /en/ or /de/ $this->related_tutor->template->fields->skills->label // always returns "skills" no matter the language The label for the field is set in different languages. related_movie is a related page (aka "page field") and that related page is a user, i.e. uses a system template (– might that be the issue?) Why doesn't this work for related pages? Link to comment Share on other sites More sharing options...
ngrmm Posted August 8, 2024 Share Posted August 8, 2024 @froot so related_tutor or related_movie, is a page field right? Is it a single or multiple page field? If multiple (by default), then you would need to select one from the array. like: …related_tutor->first->template->fields->skills->label and check this https://processwire.com/api/ref/field/get-label/ 1 Link to comment Share on other sites More sharing options...
da² Posted August 8, 2024 Share Posted August 8, 2024 (edited) @froot Try to replace "label" by "getLabel()". https://processwire.com/api/ref/field/get-label/ Quote Get field label for current language, or another specified language. This is different from $field->label in that it knows about languages (when installed). Edited August 8, 2024 by da² 1 Link to comment Share on other sites More sharing options...
froot Posted August 8, 2024 Author Share Posted August 8, 2024 ->getLabel() works perfectly! Thanks all! 1 Link to comment Share on other sites More sharing options...
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