When I add a new field_collection item in a content typ, the title is like "Add FIELD_COLLECTION_FIELD_LABEL_NAME". I have to set additional information for the add, edit and delete title. For this case I have altered the label calback for field_collections:

/**
 * Implements hook_entity_info_alter().
 */
function my_module_entity_info_alter(&$entity_info) {
  // Change the label callback for field collection to provide a better label name
  if (isset($entity_info['field_collection_item'])) {
    $entity_info['field_collection_item']['label callback'] = 'my_module_content_field_collection_label';
  }
}

This works great for edit and delete but not for add, because add does not use the $entity->label() function to generate the "Add ..." text and the defined label callback is not invoked.

Comments

weri’s picture

Status: Active » Needs review
StatusFileSize
new2.08 KB

I created a patch for that.

Status: Needs review » Needs work

The last submitted patch, field_collection-add_label_use_also_callback-1978398-1.patch, failed testing.

weri’s picture

Status: Needs work » Needs review
StatusFileSize
new1.8 KB

I forgot to change the file paths.

Status: Needs review » Needs work

The last submitted patch, field_collection-add_label_use_also_callback-1978398-3.patch, failed testing.

weri’s picture

Status: Needs work » Needs review
StatusFileSize
new1.9 KB
jmuzz’s picture

Priority: Major » Normal
Issue summary: View changes
damienmckenna’s picture

Version: 7.x-1.0-beta5 » 7.x-1.x-dev

Needs to be reviewed against the latest -dev release.

Status: Needs review » Needs work

The last submitted patch, 5: field_collection-add_label_use_also_callback-1978398-5.patch, failed testing.