function field_test_entity_nested_form

Form combining two separate entities.

1 string reference to 'field_test_entity_nested_form'
field_test_menu in modules/field/tests/field_test.module
Implements hook_menu().

File

modules/field/tests/field_test.entity.inc, line 423

Code

function field_test_entity_nested_form($form, &$form_state, $entity_1, $entity_2) {
    // First entity.
    foreach (array(
        'ftid',
        'ftvid',
        'fttype',
    ) as $key) {
        $form[$key] = array(
            '#type' => 'value',
            '#value' => $entity_1->{$key},
        );
    }
    field_attach_form('test_entity', $entity_1, $form, $form_state);
    // Second entity.
    $form['entity_2'] = array(
        '#type' => 'fieldset',
        '#title' => t('Second entity'),
        '#tree' => TRUE,
        '#parents' => array(
            'entity_2',
        ),
        '#weight' => 50,
    );
    foreach (array(
        'ftid',
        'ftvid',
        'fttype',
    ) as $key) {
        $form['entity_2'][$key] = array(
            '#type' => 'value',
            '#value' => $entity_2->{$key},
        );
    }
    field_attach_form('test_entity', $entity_2, $form['entity_2'], $form_state);
    $form['save'] = array(
        '#type' => 'submit',
        '#value' => t('Save'),
        '#weight' => 100,
    );
    return $form;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.