The issue

  • When using entityconnect if I edit an entity when I save the updated entity I am returned to the form where I clicked edit. (Works as expected.)
  • When using entityconnect if I add an entity when I save the new entity I am sent to the new entity's view page rather than the form where I clicked the add button. (unexpected)

A bit of background

  • I'm using the 7.x-1.x-dev release.
  • I have an entity built with ECK with updated CRUD paths (hook_entity_info_alter) that references other entities using entity reference fields and entityconnect. The other entities are built with ECK and also have updated CRUD paths.

Some other things I've noticed (might not be important)

  • When I click the edit button build_cache_id is included in the query string, however when I click the add button it isn't.

Comments

Dave Bagler created an issue. See original summary.

dave bagler’s picture

Category: Bug report » Task

It's an issue with my custom paths. In entityconnect_form_alter() on line 174 there's a check to see if it's a child form based on the position of the word 'add' in the path. Entity connect is looking for 'add' in path argument 1, but for my urls it's argument 2.

I tested by replacing arg(1) with arg(2) and the 'add' forms work as expected. So I've changed this issue category from bug to task because while it works it seems a bit rigid. @jygastaud would you be open to a patch that allowed for setting a custom 'is child' check? If so I'll get working on it.

function entityconnect_form_alter(&$form, &$form_state, $form_id) {

  ...

  if ((isset($_REQUEST['build_cache_id'])
          && ($cid = $_REQUEST['build_cache_id']))
       	  || ((arg(1) == 'add') && ($cid = arg(3)) && $child = TRUE)
          || ((arg(1) == 'people') && (arg(2) == 'create') && ($cid = arg(3)) && $child = TRUE)
          || ((arg(2) == 'taxonomy') && (arg(4) == 'add') && ($cid = arg(5)) && $child = TRUE)
          || ((arg(2) == 'taxonomy') && (arg(3) == 'add') && ($cid = arg(4)) && $child = TRUE)
          || ((arg(2) == 'entity-type') && (arg(5) == 'add') && ($cid = arg(6)) && $child = TRUE)) {
   
...

jygastaud’s picture

Hi Dave,

First, thanks to offer working on that piece.

I've already worked on something close in 7.x-2.x branch.

I've decided to completly remove controls on entity_types or any "add" for having a more generic way to deal with any kind of entities.

Did you try the 7.x-2.x branch ?

dave bagler’s picture

Hi Jean-Yves,

I did try the 2.x branch but I ran into some other issues, if I was just starting now I would probably switch. For now I've just updated my custom CRUD paths so that 'add' is in the arg(1) position and everything works fine. So rather than making a code change maybe a documentation change would be enough? I can write something up for the FAQ in the readme.

Thanks for the quick reply.

jygastaud’s picture

Can you try to backport the change from 2.x to 1.x and told me if 1. it solves your issue, 2. you see any side effect ?

I think you should be able to just copy/paste the code from underlying lines in github (see previous link).

dave bagler’s picture

Yeah I'll take a look.

dave bagler’s picture

StatusFileSize
new1.98 KB

I didn't have a chance to take a look at the 2.x code and back port it to 1.x. I ended up just reworking the existing if statement to make it more general and it solves my problem. I rolled it into a patch incase it is helpful for anyone else.

lrodarte’s picture

Is this supposed to be fixed in a version?

I had the 7.x-2.0-rc1 version installed, and then tried the 7.x-2.x-dev. The problem occurs in both versions.

dave bagler’s picture

This is in the 1.x-dev release.

cgv’s picture

StatusFileSize
new547 bytes

Hi, I have a similar problem using version 7.x.2.0-rc1. When I edit the select entity in the parent form and add a field collection item in the child form and submit it. Then, I get on the view page of the child content. I fix with the attached patch.

Regards

jkingsnorth’s picture

jsibley’s picture

I may be running into a similar issue. I am using entityform and when I click on the add button, the url is:

[mysite]admin/structure/entity-type/project_survey/project_survey/add/entityconnect-form-mP5vVhjefvU9FlXG-UA3Lx8A00aiiXI_Yu4HzXJxn40

When I click on "save", I am returned to the page that views the created entity ([entityname]/[bundlename]/[entityid]) instead of returning me to the entityform.

Just in case it helped, I tried the patch referred to in comment #11 above. It doesn't seem to make a difference.

Also, I see this in my log, which might be related:

Notice: Undefined property: Entity::$id in entityconnect_eck_entityconnect_child_form_submit_alter() (line 115 of [mysite]/sites/all/modules/entityconnect/modules/entityconnect_eck/entityconnect_eck.module).

Thanks for any thoughts on this.

astonvictor’s picture

Status: Active » Closed (outdated)

D7 reached its EOL back in January 2025, and there is no active release for D7 for this module anymore.
Development or support is not planned for D7. All D7-related issues are marked as outdated in a bunch.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.