hi,
the add or edit links don't appear on node form below entity reference field for a custom entity (created with ECK module).
The search link is here, after creating a view.
I tried a dummy nodereference with article content type and it's working (add, edit ... links showing).

something is missing with my custom entity ?

thanks

Comments

zhgenti’s picture

Hi,

Try adding this hook

function hook_references_dialog_entity_admin_paths() {
  return array(
    'asset' => array(
      'add' => 'my/entity/add/path/[bundle-sanitized]',
      'edit' => 'my/entity/edit/path/[entity_id]',
    ),
  );
}
mich5’s picture

hi,
thanks for the answer.
I tried this way:
(entity and bundle created with eck module, not code)
create an budget.module

adding code, but not sure about paths

<?php
function budget_references_dialog_entity_admin_paths() {
  return array(
    'asset' => array(
      'add' => 'admin/structure/entity-type/budget/[a_bundle_name]',
      'edit' => 'budget/a_bundle_name/[entity_id]',
    ),
  );
}
?>

I still have not the links (add then edit with ref added).
I will try another solution maybe.

AaronBauman’s picture

"asset" is supposed to be the name of your entity type.
and "[bundle-sanitized]" and "[entity_id]" are literally supposed to go in as-is.

for example, here's the implementation for "bean" module:
http://drupal.org/files/references-dialog-bean-0.patch

See also:
#1836892: Compatibility with References Dialog

eliaspallanzani’s picture

work for me after clearing cache.

for a newbye:
1. download eck module, unzip, find eck.module
2. patch with https://drupal.org/node/1836892 OR manually add to eck.module :

function eck_references_dialog_entity_admin_paths() {
$admin_paths = array();
$path = eck__entity_type__path();
foreach (EntityType::loadAll() as $entity_type) {
$admin_paths["{$entity_type->name}"] = array(
'add' => "{$path}/{$entity_type->name}/[bundle-sanitized]/add",
'edit' => "{$path}/{$entity_type->name}/[bundle-sanitized]/[entity_id]/edit"
);
}
return $admin_paths;
}

3. upload the edited file with ftp.
4. clear cache.

micnap’s picture

I've got an entity type created by a contrib module (Redhen). I've added the hook_references_dialog_entity_admin_paths() hook to my custom module, cleared cache and am still not seeing the add link. I am seeing the Search link. Any ideas? What could possibly be missing?

function mymodule_references_dialog_entity_admin_paths() {
  return array(
    'redhen_org' => array(
      'add' => 'redhen/org/add/[bundle-sanitized]',
    ),
  );
}

Thanks,
Mickey

micnap’s picture

Nevermind. I'm a moron. I was using the entity type of the parent entity, not the entity I wanted to create. Works great. Thanks!

Mickey

profak’s picture

Hello!
My problem is that i used hook_references_dialog_entity_admin_paths() to add support for my custom entity.
Well, it didn't work! I tried to use xdebug and set breakpoint into hook - so it never fires! I'm confused right now and have no idea what to do.

function sitename_mods_references_dialog_entity_admin_paths() {
  // variable for breakpoint - never fires
  $a = "";
  return array(
    'special_offer' => array(
      'add' => 'admin/custom-entity/special_offer/add',
      'edit' => 'admin/custom-entity/special_offer/[entity_id]/edit',
    ),
  );
}

Thanks!

UPD: Maybe something wrong with my entity?!

AaronBauman’s picture

did you clear the site cache?
is this function in sitename_mods.module? if not, is the file this function is in getting loaded?
is sitename_mods module enabled?

also your implementation is still not quite right.
in your case "special offer" would be an entity, and you're implementing this hook in order to be able to create bundles for the entity.
so, it should be:

function sitename_mods_references_dialog_entity_admin_paths() {
  // variable for breakpoint - never fires
  $a = "";
  return array(
    'special_offer' => array(
      'add' => 'admin/special_offer/[bundle-sanitized]/add',
      'edit' => 'admin/special_offer/[bundle-sanitized]/[entity_id]/edit',
    ),
  );
}

finally, judging from your implementation, maybe you don't actually need to create a custom entity?

profak’s picture

Thank you for answer aaronbauman!

I tried eck to create entity and tried hook_mods_references_dialog_entity_admin_paths() aganist just created entity - everything works great.
That means, that i got everything about this hook and problem is in my code-implementation of my custom entity (special_offer).

So i have to find what's the matter with my entity.

Thanks a lot!

jaydub’s picture

Status: Active » Closed (works as designed)

Seems to me adding the hook as described above and noted in references_dialog.api.php file in the module gets the job done.

fakir22’s picture

Issue summary: View changes

zhgenti's solution (#1) worked perfectly for my custom entities written directly in code, not with ECK.

function MY_MODULE_NAME_references_dialog_entity_admin_paths() {
  return array(
    'MY_ENTITY_NAME' => array(
      'add' => 'admin/MY_ENTITY_NAME/add',
      'edit' => 'admin/MY_ENTITY_NAME/[entity_id]/edit',
    ),
  );
}

Thanks a lot

Yuri’s picture

The latest ECK release has the code mentioned in #4 in eck.referenced_dialog.inc
However, for me sometimes this works, sometimes the links don't show up. I still have to see what causes them not to appear.

slimedidi’s picture

@Yuri
Do you find a way to work it out?

For me, it doesn't work.
If I login as Admin user role, it does work.
If I login as other user role with eck add permission, it doesn't work.
However, if I check "Add Entities" permission with other user role, it does work.....