Jump to content

what is labelFieldName attribute for?


pogidude
 Share

Recommended Posts

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

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

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

  • 1 month later...

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...