esafwan
8/9/2014 - 4:46 PM

Drupal Load Custom Entity Edit Form

Drupal Load Custom Entity Edit Form

/*
## Parameters
$entity_type: The entity type for which to get the form.

$entity: The entity for which to return the form. If $op is 'add' the entity has to be either initialized before calling this function, or NULL may be passed. If NULL is passed, an entity will be initialized with empty values using entity_create(). Thus entities, for which this is problematic have to care to pass in an initialized entity.

$op: (optional) One of 'edit', 'add' or 'clone'. Defaults to edit.

$form_state: (optional) A pre-populated form state, e.g. to add in form include files. See entity_metadata_form_entity_ui().

##Return value

The fully built and processed form, ready to be rendered. */

$entity_form = entity_ui_get_form('profile2', $profile2, 'edit'); // Or 'add'
print drupal_render($entity_form);