pogidude Posted June 19, 2013 Share Posted June 19, 2013 when creating and adding a field to a fieldgroup: //add role_add_children_pages $field_addable = new Field(); $field_addable->name = 'role_add_children_pages'; $field_addable->label = 'Pages users with this role may add to'; $field_addable->labelFieldName = 'path'; $field_addable->type = wire('modules')->get('FieldtypePage'); $field_addable->inputfield = 'InputfieldPageListSelectMultiple'; $field_addable->description = 'In order to add to child pages, this role must have page-edit permission or the user must also have another role with page-edit permission.'; $field_addable->save(); $this->message("Added field 'role_addable_pages' to the role template."); $fieldgroup = $this->fieldgroups->get('role'); $fieldgroup->add($field_addable); $fieldgroup->save(); I'm curious what the labelFieldName attribute is for. the one assigned with 'path' Link to comment Share on other sites More sharing options...
ryan Posted June 20, 2013 Share Posted June 20, 2013 labelFieldName is specific to InputfieldPage. It identifies the field that you want to use as the selectable label. Typically this would be 'title', but for something that doesn't have a title 'path' would be a good choice. Link to comment Share on other sites More sharing options...
pogidude Posted June 20, 2013 Author Share Posted June 20, 2013 So if my field was: $field_templates = new Field(); $field_templates->name = 'role_permitted_templates'; $field_templates->label = 'Templates users with this role may use on pages they can add to'; $field_templates->labelFieldName = 'path'; $field_templates->type = wire('modules')->get('FieldtypeText'); $field_templates->inputfield = 'InputfieldPageName'; I don't need to specify the labelFieldName since this is basically just a text field right? Link to comment Share on other sites More sharing options...
pogidude Posted June 21, 2013 Author Share Posted June 21, 2013 never mind. I get it now. just tried setting the labelFieldName to 'title' on a FieldtypePage and got the list shown on the field showed titles instead of paths. very cool 1 Link to comment Share on other sites More sharing options...
owzim Posted August 6, 2013 Share Posted August 6, 2013 Ryan, I have the problem that the labelFieldName is rendered only unformatted. How can I force it to be rendered with formatting considered? Currently I am using a workaround with the Concatenate Fieldtype where I can force the formatting with an exclamation mark. Link to comment Share on other sites More sharing options...
ryan Posted August 8, 2013 Share Posted August 8, 2013 labelFieldName renders unformatted in order to keep anything from potentially breaking in the admin. It routes all output through htmlentities() just to ensure its suitable for display. That's the only safe way to do it. The workaround you mentioned is the correct way to do it with the Concatenate Fieldtype. 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