I wanted to set the title to the place name. The attached patch could be made dynamic like the other fields. But, this was a good improvement for my project.

CommentFileSizeAuthor
gp-autoset-title.patch466 bytesgreg boggs

Comments

Greg Boggs created an issue. See original summary.

hargobind’s picture

At the moment, the module has this line which works for Nodes:
$entity->title = (trimed/cleaned-up version of $place['name']);

I understand that your patch is meant to work for Entities which tend to use $entity->label.

Do you think it would cause any problems to just add $entity->label after $entity->title, or should I do a more extensive check for the correct label property as demonstrated in entity_label() (i.e. ['label callback'] or ['entity keys']['label'])?

tyler.frankenstein’s picture

label won't work across entity types, i.e. for nodes it is title, for taxonomy terms its name, for comments it's subject, etc

A dynamic approach to finding the correct label machine name is the right method.

greg boggs’s picture

That's not surprising. Mostly, I just needed the patch for entity, so that my GP entities had titles. But, a better solution would be ideal.

tyler.frankenstein’s picture

Greg, I'm curious, are you using ECK to create custom entity types, or rolling your own via a custom module? I ask because AFAIR the ECK module uses the title field to store entity titles. If you're using a custom module, I'm guessing you're able to specify the machine name of the label...?

  • hargobind committed f7fe25a on 7.x-1.x
    Issue #2902415: $entity->title was being set to the place name, but that...
hargobind’s picture

I just committed a fix to the dev branch that should detect an entity's "label" property. It seems to work correctly for nodes, taxonomy terms, and custom entities. Would y'all be available to test it?

greg boggs’s picture

Almost all of ThinkShout's modules rely on entities. MailChimp, Registration, Redhen, Salesforce... In this case, I was using this module to set the address on a RedHen organization. So, when a user selects their location, I create an organization for them with the correct address from GP.

  • hargobind committed 47b0de7 on 7.x-1.x
    Issue #2902415: Added a "Set Title/Label" checkbox to the Field Instance...
hargobind’s picture

Status: Active » Fixed

I made a checkbox on the field instance settings form for "Set title/label" to be optional. I think it's ready for prime-time.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.