You are here

function afb_new_block_create_form_submit in Advanced Form Block 7

Submit handler for the create block form facilitating its deletion.

1 string reference to 'afb_new_block_create_form_submit'
afb_new_block_create_form in ./afb.module
Displays the form enabling the creation of new blocks.

File

./afb.module, line 208
Allows administrators to create blockd of node add/edit forms.

Code

function afb_new_block_create_form_submit($form, $form_state) {
  $v = $form_state['values'];
  $nids = !empty($v['nid']) ? $v['nid'] : 0;
  $data = serialize(array());
  if (!empty($v['content_type'])) {
    $type = $v['content_type'];
  }
  else {
    $node = node_load($nids);
    $type = $node->type;
  }
  $nid = db_insert('afb_blocks_data')
    ->fields(array(
    'title',
    'content_type',
    'form_type',
    'nid',
    'data',
  ))
    ->values(array(
    'title' => $v['title'],
    'content_type' => $type,
    'form_type' => $v['block_type'],
    'nid' => $nids,
    'data' => $data,
  ))
    ->execute();
  if (isset($nid)) {
    drupal_set_message(t('The Block has been succesfully created'));
  }
  else {
    drupal_set_message(t('Error creating the block'));
  }
}