I have been using Profile 8.x-1.0-alpha5 on my site for several months without issue. I have now upgraded to Drupal 8.4 and am now trying to upgrade Profile to 8.x-1.0-rc1. Once upgraded however all of my profiles have had their "Label" changed. For example:

The profile type is called "Company". On 8.x-1.0-alpha5 my profile labels were:

Company profile of BMW
Company profile of Ford
Company profile of Honda

but on 8.x-1.0-rc1 these have changed to:

Company profile #1
Company profile #2
Company profile #3

Please can you tell me why this is happening and how to fix it? Thanks!

Tom

Comments

DarkstarTom created an issue. See original summary.

pradeepjha’s picture

I'm using beta-1 version even that has also same issue. Profile label is showing like:

profile profile #1
profile profile #2
profile profile #3

My profile type is "Profile". Is there anyway we can fix this to make proper label?

maaty388’s picture

This was changed in this issue. There is code for label

public function label() {
    $profile_type = ProfileType::load($this->bundle());
    $label = $this->t('@type profile #@id', [
      '@type' => $profile_type->label(),
      '@id' => $this->id(),
    ]);
    // Allow the label to be overridden.
    $event = new ProfileLabelEvent($this, $label);
    $event_dispatcher = \Drupal::service('event_dispatcher');
    $event_dispatcher->dispatch(ProfileEvents::PROFILE_LABEL, $event);
    $label = $event->getLabel();

    return $label;
  }

If this works as expected you should be able to override your label. I am not sure how exactly you can change label but there is a new event so I am sure this is working just fine.

jasonawant’s picture

fixing this for site requires writing code, need to add event subscriber to this new PROFILE_LABEL event.

I think the module would better serve more users by providing a configuration option to the ProfileTypeForm that would allow site builders to use tokens or something.

maaty388’s picture

I was thinking to set token module as dependency and then on this path /admin/config/profile/profile-settings would be for now one text field with token extension... And for a default value, I would set as it's now '@type profile #@id'. Also, I don't really know where to put menu link, for now, I just put it under config-> profile types -> Profile Form...
We need to discuss that before implementing this into a module.
I think it would be really user-friendly if there is an available form where you can set different options, and you don't need to change everything programmatically, at this point I don't even know if its possible to change profile labels?
Waiting for feedback

maaty388’s picture

Here is the patch and work done so far.
Need to figure out how to get replaced tokens so they can be used as a label. It can be a little bit tricky because I don't know what parameters need to be passed to replace function.

maaty388’s picture

Status: Active » Needs work
drupgirl’s picture

Thanks for starting this. The generic label causes pain when you go to use an entity reference field and see a long list of "Member profile #1, etc., ". Using token fields from the profile type or the user would be ideal. +1 for feature request. https://www.drupal.org/project/profile/issues/2900573

bojanz’s picture

Version: 8.x-1.0-rc1 » 8.x-1.x-dev
Status: Needs work » Closed (duplicate)