function field_test_entity_form

7.x field_test.entity.inc field_test_entity_form($form, &$form_state, $entity, $add = FALSE)

Test_entity form.

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

File

drupal-7.x/modules/field/tests/field_test.entity.inc, line 344
Defines an entity type.

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;
}