Can this module reference any entity since I can see the option to choose any entity on my site, but when I view edit form field dosent show at all. Am I missing something or this is not implemented yet?

Comments

rogical’s picture

what entities? Currently it only supports commerce entities and nodes.

bojanz’s picture

I don't understand.
Are you looking to reference existing entities, or looking to use this module on other entity types (that aren't commerce_product or node)?

dmiric’s picture

I would like to use it with ECK entities.

bojanz’s picture

Status: Active » Fixed

You will need to write a controller for any extra entity type (see the node one that ships with IEF as an example).
Not sure if that means 1 controller for all ECK types, or one per ECK type.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Component: User interface » Code
Category: support » feature
Status: Closed (fixed) » Needs review
StatusFileSize
new2.25 KB

Hi

Attached is a patch for supporting ECK entities.
I also created a submodule in a sandbox, but for the few changes, a patch is preferred.
Sandbox: http://drupal.org/sandbox/timleytens/1808436

Greets

TimLeytens

victory17’s picture

I also wanted to add a note, the patch above does this for eck entities. But for a quick and easy way to support a custom entity you can also add

'inline entity form' => array(
		'controller' => 'yourenityinlinecontroller',
		),

To your entity_info declaration. Then you can override the inlineentityformcontroller provided by the inline Enity form module. The readme file is a little vague on this.

Jorrit’s picture

Title: Refrence other entities » Reference ECK entities

Patch #6 doesn't allow me to enter any fields except the title, although I have selected just one ECK entity bundle and that bundle has extra fields.

This is because $entity->type is given as the first argument to field_attach_form(), but $entity->type contains the bundle, not the entity type name. In a lot of cases, this is the same, but for me it wasn't.

The right code is:

field_attach_form($entity_form['#entity_type'], $entity, $entity_form, $form_state, LANGUAGE_NONE);

I hope this can be committed quickly!

stevector’s picture

StatusFileSize
new2.23 KB

Thanks Jorrit. This revision of the patch corrects that problem with $this->entityType instead of $entity_form['#entity_type'] as it's a little more direct.

Jorrit’s picture

I did't know that $this->entityType existed, thanks for correcting that. One little remark however: I now see that the patch adds an explicit title field. It is possible to unselect the title field for an entity. Does your patch take that into account?

stevector’s picture

I only changed the one line in the patch and can't explain the extra title field. TimLeytens, do you know what that is for?

Anonymous’s picture

Title is a required field for every (ECK) entity. But title is an entity property and field_attach_form only adds the field API fields to the entity, not the entity property fields.

Greets

TimLeytens

Jorrit’s picture

Tim: this may have changed recently, but when I create an entity type, I get the choice if I want a title field or not. The complete list of choices is title, created, changed and author. The selected properties are available in EntityType::loadByName('ENTITY_TYPE')->properties.

Maybe it is better to reuse the existing form from eck__entity__form().

Anonymous’s picture

StatusFileSize
new2.02 KB

Indead, I thought title was required, we could use following patch.

I unset the submit, because Inline entity form adds his own buttons

Greets

TimLeytens

pebosi’s picture

Patch #14 works for me

garphy’s picture

Patch in #14 works for me.

garphy’s picture

It may be worth noting that the proposed implementation does not integrate the hooks form_validate and form_submit from ECK. They actually do more or less the same that IEF's default controller implementation as they both invoke entity API in the end but we should be aware that future evolution of ECK could lead to force us to implement a custom entityFormValidate() & entityFormSubmit() implementations.

(my .02€ tough)

bojanz’s picture

Title: Reference ECK entities » Add support for Inline Entity Form
Project: Inline Entity Form » Entity Construction Kit (ECK)

I think this integration should live inside the ECK module.

aptorian’s picture

StatusFileSize
new1.98 KB

The above patch was not applying on the latest release for me... seems like it went off by a line or something. Applied changes manually and made a new patch, if anyone needs it.

adamelleston’s picture

Has anyone else tried the path in #19 as it doesn't seem to work for me. Not sure if i am doing something wrong or not.

Jorrit’s picture

It is a patch for the Inline Entity Form module, not for the ECK module. The project for this issue was changed. The patch works for me.

acrazyanimal’s picture

Um .. first I would like to say inline entity form is awesome!

So, I have re-rolled the patch from #14 to apply against the latest eck 7.x-2.x snapshot. I would love to commit this as it just made my mind explode!!! However, it would be great if some others could test this patch out and supply some feedback. Once its marked RTBC I'll commit it.

acrazyanimal’s picture

Forgot to click attach for the patch .. here it is

 ||
\  /
 \/
garphy’s picture

patching fails here

simon@dev:~/eck$ patch -p1 < eck-inline_entity_form_support-1689726-21.patch
patching file eck.entity_type.inc
Hunk #1 succeeded at 328 with fuzz 2 (offset -69 lines).
patching file eck.info
Hunk #1 FAILED at 7.
1 out of 1 hunk FAILED -- saving rejects to file eck.info.rej
patching file includes/eck.inline_entity_form.inc

Are you sure it's rolled against 2.x-dev and not 1.x-dev ?

garphy’s picture

patching fails here

nevermind...
i checked out the wrong git branch.

the patch apply cleanily, i'll test it out

acrazyanimal’s picture

Hmm, yep I am absolutely certain it was against 7.x-2.x branch. I tested the patch as well git apply -v eck-inline_entity_form_support-1689726-21.patch and it worked fine for me. I had freshly cloned 7.x-2.x.

acrazyanimal’s picture

:)

garphy’s picture

What's weird is that is does apply cleanily on a git clone but not on the 7.x-2.x-dev tgz (tested trough drush make)
I think it's because of the additional information that d.o adds when it packages the module

maybe if we remove the comments you added in the .info in the patch it will apply more easily. I'll test that out

acrazyanimal’s picture

Probably the case. I don't think its necessary to apply it against the tar since it will be committed on top of the 7.x-2.x HEAD and drupal will add the packaging info to the bottom of what it there. So there won't be conflicts once its committed.

acrazyanimal’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

Gaelan’s picture

+++ b/includes/eck.inline_entity_form.incundefined
@@ -0,0 +1,30 @@
+  public function labels() {
+    $entity_info = entity_get_info($this->entityType);
+    $labels = array(
+      'singular' => $entity_info['label'],
+      'plural' => $entity_info['label'],
+    );
+    return $labels;
+  }

This might be better for a separate issue, but we really should use a proper plural form here. Not sure how do do it offhand other than adding a "Plural Form" field to the config.

acrazyanimal’s picture

@Gaelan: Can you make this a separate issue please.

  • Commit 9f19368 on 7.x-2.x, change_paths, own_permissions, 7.x-2.x-property-widgets, 7.x-3.x, entity_reference, 7.x-3.x-settings, 7.x-2.0.x, 7.x-2.1.x authored by TimLeytens, committed by acrazyanimal:
    Issue #1689726 by acrazyanimal, TimLeytens: Add support for the inline...

  • Commit 9f19368 on 7.x-2.x, change_paths, own_permissions, 7.x-2.x-property-widgets, 7.x-3.x, entity_reference, 7.x-3.x-settings, 7.x-2.0.x, 7.x-2.1.x authored by TimLeytens, committed by acrazyanimal:
    Issue #1689726 by acrazyanimal, TimLeytens: Add support for the inline...

  • Commit 9f19368 on 7.x-2.x, 7.x-3.x, 8.x authored by TimLeytens, committed by acrazyanimal:
    Issue #1689726 by acrazyanimal, TimLeytens: Add support for the inline...

  • Commit 9f19368 on 7.x-2.x, 7.x-3.x, 8.x authored by TimLeytens, committed by acrazyanimal:
    Issue #1689726 by acrazyanimal, TimLeytens: Add support for the inline...
Rastra’s picture

Issue summary: View changes

I am new to Drupal but looking at the Inline Entity Form, it is great and will solve many of my current requirements. In my project I building all the entities using Entity API and not ECK. These entities are referenced.

Now I want to make sure that they can use the features provided by Inline Entity Form. What codes I need to write in my module so that it is cable of using the Inline Entity Form.

Rastra’s picture

OK, I have tried and I could get the buttons but it is giving me the AJAX error "Unsupported Operand Type on line 1808 of durpal/include/forms.inc". I am sure someone must have done it before and if it can be extended for ECK entity, it should be possible for others as well. Any suggestion will be great.

I have been able to show the form inline and save the data but the data is not being displayed in the table for edit and delete. Some help will be appreciated.

mengi’s picture

@Rastra, this is the ECK queue and it seems like your not using ECK. You'll have a better chance of getting help by going to the inline_entity_form queue and asking there.

Also try avoiding posting in closed issues since most people will not notice your comment.