function entity_example_basic_form

Form function to create an entity_example_basic entity.

The pattern is:

  • Set up the form for the data that is specific to your entity: the columns of your base table.
  • Call on the Field API to pull in the form elements for fields attached to the entity.

Related topics

2 string references to 'entity_example_basic_form'
entity_example_basic_add in entity_example/entity_example.module
Provides a wrapper on the edit form to add a new entity.
entity_example_menu in entity_example/entity_example.module
Implements hook_menu().

File

entity_example/entity_example.module, line 414

Code

function entity_example_basic_form($form, &$form_state, $entity) {
    $form['item_description'] = array(
        '#type' => 'textfield',
        '#title' => t('Item Description'),
        '#required' => TRUE,
        '#default_value' => $entity->item_description,
    );
    $form['basic_entity'] = array(
        '#type' => 'value',
        '#value' => $entity,
    );
    field_attach_form('entity_example_basic', $entity, $form, $form_state);
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Save'),
        '#weight' => 100,
    );
    $form['delete'] = array(
        '#type' => 'submit',
        '#value' => t('Delete'),
        '#submit' => array(
            'entity_example_basic_edit_delete',
        ),
        '#weight' => 200,
    );
    return $form;
}