Closed (fixed)
Project:
Entity Construction Kit (ECK)
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
7 May 2013 at 09:50 UTC
Updated:
9 May 2013 at 02:51 UTC
I am trying to use the entity_form() function to output the edit form for an entity on my page. Seems simple...
The function returns FALSE which seems to be due to the entity info not having any result for "form callback".
After a few hours, the closest I can find is someone who seems to have hacked around it in his own sandbox module. http://drupalcode.org/sandbox/marmalade/1921824.git/blob/c3188bb232fb07c...
There must be a clean way to do this within the ECK module, but I'm afraid my head is swimming trying to understand the relationship between ECK and Entity API. Do they produce different kinds of entities? So confusing.
Comments
Comment #1
fmizzell commentedThat is true, eck does not define a form callback in the info array, but that is something trivial to add. The form function is eck__entity__form. So a calling drupal_get_form("eck__entity__form", $entity); should do the trick. ECK also provides a couple of wrapper functions that actually create/or load the entity for you and returns the form, these are eck__entity__add, and eck__entity__edit. All this function are in eck.entity.inc. Hope this helps.
Comment #2
Chris Gillis commentedThe problem I face is that I am working with various entity types, some that are ECK entities, and others like "user", etc.
Do I need to sniff somehow and serve either eck__entity__form, or entity_form() depending on the originating module?
Comment #3
sonictruth commentedHey Chris,
I think what you want to do is add the ECK form callback to the entity info array using hook_entity_info_alter()
This is effectively what we did to add ECK support to Entity Dialog.
You can add anything you like to the entity info array and it will persist through to where ever you need it.
Something like this should do the trick for you.
All that being said it would be great—if there are any ECK maintainers watching—for ECK to do this itself thereby enabling us to use the nice functions that the entity module provides in conjunction with ECK out of the box.
Comment #4
fmizzell commentedand backported to 2.x