Provides helper functions for creating forms that display multiple entities, of multiple types, showing selected fields. This can also include new, unsaved entities.
Example:
// Create a form builder as normal.
function my_form($form, &$form_state) {
// Define an array of data for the entities to show in the form.
$entity_data = array();
// First entity: node 1.
$entity_data[] = array(
'entity_type' => 'node',
'entity' => node_load(1),
'fields' => array('field_foo', 'field_bar'),
'fieldset' => t('My First Node'),
);
// Second entity: node 2.
$entity_data[] = array(
'entity_type' => 'node',
'entity' => node_load(2),
// 'fields' not given: all fields shown.
);
$form += multiple_entity_form($form, $form_state, $entity_data);
// Add your submit button and other form elements you need.
return $form;
}
function my_form_validate($form, &$form_state) {
multiple_entity_form_validate($form, $form_state);
}
function my_form_submit($form, &$form_state) {
multiple_entity_form_submit($form, $form_state);
// Save the entities.
foreach ($form['#entity_form_keys'] as $form_key) {
$entity_type = $form[$form_key]['#entity_type'];
$entity = $form[$form_key]['#entity'];
entity_save($entity_type, $entity);
}
}
Project information
Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed.Maintenance fixes only
Considered feature-complete by its maintainers.- Project categories: Developer tools
106 sites report using this module
- Created by joachim on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.
