You are here

function entity_block_form_submit in Entity Blocks 7

Submit handler for entity_block_form form.

File

./entity_block.module, line 410
Display entities (via view modes) as fieldable blocks.

Code

function entity_block_form_submit($form, &$form_state) {
  $entity_block = $form_state['values']['entity_block'];

  // Set values from form.
  $entity_block->title = $form_state['values']['title'];
  $entity_block->target_entity_type = $form_state['values']['target_entity_type'];
  $entity_block->target_bundle = $form_state['values']['target_bundle'];
  $entity_block->target_view_mode = $form_state['values']['target_view_mode'];
  $entity_block->target_entity_id = $form_state['values']['target_entity_id'];

  // Save fields.
  field_attach_submit('entity_block', $entity_block, $form, $form_state);

  // Save entity
  $entity_block = entity_block_save($entity_block);

  // Show a success message.
  $message = t('The entity block%titlehas been saved. !click to assign it to a region.', array(
    '%title' => !empty($entity_block->title) ? ' ' . $entity_block->title . ' ' : ' ',
    '!click' => l(t('Click here'), 'admin/structure/block/manage/entity_block/' . $entity_block->entity_block_id . '/configure'),
  ));
  drupal_set_message($message);
  $form_state['redirect'] = 'admin/structure/entity-blocks/manage';
}