I am working on a module with a form that allows multiple "members" to be submitted. The form allows the number of members to be specified, then displays a set of member fields that many times. This is working well, but the set of fields for each member is fixed.

I'm looking at whether it would be possible to turn it into an entity form to allow the set of fields for each member to be configured.

Is it possible for an entity form to display several sets of fields on one form, and have them all submitted together?

Any pointers on how to start?

1 Answer 1


Here is what I would do:

  1. Create that many entites as you would like to able to submit with entityTypeManager (members)

  2. Create their form objects with EntityFormBuilder->getForm($entity)

  3. Set out all the elements you don't need (their submit buttons)

  4. Add them to form like this:

    $form[$custom_form_id] = array( '#type' => 'markup', '#markup' => render($created_form), '#prefix' => '', '#suffix' => '' );

  5. In your submit, call the children form submit functions.

  • Thanks! That looks like a good starting point. Interesting idea to render the subforms rather than merge them into the main form. Commented Jun 9, 2016 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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