Hi guys,
Before I start I would like to say hello to everyone as I have just switched from Joomla. Pretty excited at the moment as I have done all tutorials on lynda.com and I am glad to be here.
What I am trying to do is pretty straightforward. I have two nodes - A and B. Node A has a reference field to Node B. When I add a new entity of Node A and save it I would like to create an entity of node B if it doesn't exists.
What I've tried is I set up an event "Before saving content", added my condition and have an action to create a new entity of Node B if the field referencing to it from Node A is filled in. The problem I have at the moment is that it doesnt create anything because I receive an error that "There are no entities matching X". Well obviously it does this validation before my action is run because otherwise if it didnt exist my rule would create this entity of Node B and then save Node A.
I've been trying many different combination but its still not working because the referencing is done before my event is fired.
What is the way to do what I need doing?
Drupal 7
Rules
Entity Reference
Thanks for all your input!
Chris
Comments
Inline Entity Form module
Hi Chris. Welcome to Drupal!
Take a look at the Inline Entity Form module (http://drupal.org/project/inline_entity_form). Hopefully that will help. :)
Element31,Thanks for your
Element31,
Thanks for your reply! Seems to be an interesting module, althought it doesnt provide any documentation. Just wondering, is there any other way to achieve what I need?
Thanks!
I've tried inline_entity_form
I've tried inline_entity_form and unfortunately after sorting problems with issues I experienced after installation it is NOT working as I supposed to. It creates a new referenced node every time I create node A instead of simply using existing nodes if they exist. It also doesnt provide a nice ajax filter you get with taxonomy. Btw taxonomy does exactly what I need and it would work great in some cases but it is not solution if for example:
Im creating a product and have a 'Store' field referencing to a store node title. It can't be a taxonomy, it needs to be a node...
Could anyone please help me out with it?
Thanks
Chris
Works for me
Sorry the module didn't work out for you. I'm using it on a current project, and it works fine for me. It allows me to either create a new node to reference or I can choose an existing node. You have to create an entity reference field via the Entity API module (http://drupal.org/project/entity) in order to use inline_entity_form. The "Inline entity form" is a widget that you use on an entity reference field.
Seems like it would solve your problem if you got it to work. Did you check out the README file for inline_entity_form? Good luck! :)