function field_test_entity_form

Test_entity form.

4 string references to 'field_test_entity_form'
FieldAttachOtherTestCase::testFieldAttachSubmit in modules/field/tests/field.test
Test field_attach_submit().
field_test_entity_add in modules/field/tests/field_test.entity.inc
Menu callback: displays the 'Add new test_entity' form.
field_test_entity_edit in modules/field/tests/field_test.entity.inc
Menu callback: displays the 'Edit exiisting test_entity' form.
ListFieldTestCase::testUpdateAllowedValues in modules/field/modules/list/tests/list.test
Test that allowed values can be updated.

File

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

Code

function field_test_entity_form($form, &$form_state, $entity, $add = FALSE) {
    // During initial form build, add the entity to the form state for use during
    // form building and processing. During a rebuild, use what is in the form
    // state.
    if (!isset($form_state['test_entity'])) {
        $form_state['test_entity'] = $entity;
    }
    else {
        $entity = $form_state['test_entity'];
    }
    foreach (array(
        'ftid',
        'ftvid',
        'fttype',
    ) as $key) {
        $form[$key] = array(
            '#type' => 'value',
            '#value' => isset($entity->{$key}) ? $entity->{$key} : NULL,
        );
    }
    // Add field widgets.
    field_attach_form('test_entity', $entity, $form, $form_state);
    if (!$add) {
        $form['revision'] = array(
            '#access' => user_access('administer field_test content'),
            '#type' => 'checkbox',
            '#title' => t('Create new revision'),
            '#default_value' => FALSE,
            '#weight' => 100,
        );
    }
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Save'),
        '#weight' => 101,
    );
    return $form;
}

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