suntrop Posted October 13, 2017 Share Posted October 13, 2017 I would like to use the label for roles, as the label is used for templates. My role names are more technical and in englisch, but I would like to give them a more readable and lengthier name. When I edit the "role" template there is no field "templateLabel" I can add. Link to comment Share on other sites More sharing options...
dragan Posted October 13, 2017 Share Posted October 13, 2017 Where do you need this "label" to be visible? You could try adding a title field to the role template. This way, when you drill down the admin page-tree, you will see the title instead of the name. 1 Link to comment Share on other sites More sharing options...
suntrop Posted October 13, 2017 Author Share Posted October 13, 2017 13 minutes ago, dragan said: Where do you need this "label" to be visible On the user-edit page for example Link to comment Share on other sites More sharing options...
suntrop Posted October 13, 2017 Author Share Posted October 13, 2017 I had added the title filed to the roles template. And I found I can configure the roles module to display other fields in the listing under Access > Roles – but currently I found no way to display the title instead the name on the user profile pages. Link to comment Share on other sites More sharing options...
adrian Posted October 13, 2017 Share Posted October 13, 2017 1 hour ago, suntrop said: but currently I found no way to display the title instead the name on the user profile pages. What about this in your ready.php file: $this->addHookBefore("InputfieldCheckboxes::render", function($event) { if($event->object->id != 'Inputfield_roles') return; $optionsWithTitles = array(); foreach($event->object->options as $id => $name) { $roleTitle = $this->wire('roles')->get($id)->title; $optionsWithTitles[$id] = $roleTitle != '' ? $roleTitle . ' ('.$name.')' : $name; } $event->object->options = $optionsWithTitles; }); In this screenshot I have only added a title to the "Editor" role: 5 Link to comment Share on other sites More sharing options...
suntrop Posted October 14, 2017 Author Share Posted October 14, 2017 That is great! Many thanks. 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