Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose, I've two entities:


A user creates an entityA and has the option of creating multiple types of entityB referenced from a single entityA. For example, a parent-child relationship. Parent being entityA and child being entityB.

In the module, I want the users to select an entityA object, go to a new page page for creating entityB. So, at this point, (add-form of entityB) I should have the data of that particular entityA object that the user clicked on.

So, far I'm able to get "all" the data of entityA on the add-form of entityB, which is of no help as I'm unable to get the specific id of entityA.

The relevant code are:


  path: '/admin/config/mymodule/{entityA}/entityB/add'
    _entity_form: 'mymodule_entityA_entityB.default'
    _title: 'EntityB'
    _entity_create_access: 'mymodule_entityA'

When, I'm shown the form addition page of entityB (type: ../../testentitya/entityA/add), how do I pass the entityA object to the form and what will be the structure of entityB's config schema?

share|improve this question
"entityB's config schema" -- is entityB a config entity?? – user49 Jul 24 '14 at 8:40
@chx: Yes. Both entities are config entity. – xan Jul 24 '14 at 8:44
I don't understand the difference of this question to drupal.stackexchange.com/questions/124065/…? seems exactly the same to me and does answer the question IMHO. Yes, it uses content and config entities/bundles, but that doesn't really matter. – Berdir Jul 25 '14 at 21:19
@Berdir: Yes, they don't have any difference. I've already flagged it for moderators asking them to delete it. After posting this question, I realized I should have edited that one. My bad. – xan Jul 26 '14 at 18:43

Regarding the references: config entities are simple beasts. Entity references are only supported on content entities; however you are on the way of building it out yourself tailored for your needs. So, just store a string with the id of configA and that's about it. What you do with a string is your call.

share|improve this answer

Have a look at https://www.drupal.org/node/2310425

This should explaine everything needed.

Here is an example how it would look like:

  path: '/admin/config/mymodule/{entityA}/{entityB}/add'
    _entity_form: 'mymodule_entityA_entityB.default'
    _title: 'EntityB'
    _entity_create_access: 'mymodule_entityA'
        type: entity:entity_type_a
        type: entity:entity_type_b
share|improve this answer
The example doesn't make too much sense to me, as you're adding an entityB, you can't pass anything to it? You only pass around entityA? – Berdir Jul 25 '14 at 21:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.