You are here

function hook_flexiform_prepare_base_entity in Flexiform 7

Prepare the base entity of a flexiform.

Parameters

$base_entity: The base entity of the form, provided by the FlexiformDisplay.

Flexiform $flexiform: The flexiform that is about to be built.

FlexiformDisplayBase $display: The flexiform display handler that has provided the base entity.

See also

FlexiformDisplayBase::build()

2 invocations of hook_flexiform_prepare_base_entity()
FlexiformDisplayBase::build in includes/flexiform.display.inc
Build the form ready for rendering.
FlexiformDisplayCreateModal::build in includes/display/add_modal.display.inc
Build the form ready for rendering.

File

./flexiform.api.php, line 336
API documentation for Flexiform.

Code

function hook_flexiform_prepare_base_entity($base_entity, Flexiform $flexiform, FlexiformDisplayBase $display) {
  global $user;

  // Default an entity reference field to the current user id.
  // This allows the form to use the entityreference getter to load this
  // user into the form.
  if ($flexiform->form == 'node_create_form') {
    $base_entity->field_author[LANGUAGE_NONE][0] = array(
      'target_id' => $user->uid,
    );
  }
}