function entityform_block_submit in Entityform block 7
Custom submit function.
1 string reference to 'entityform_block_submit'
- entityform_block_form_alter in ./
entityform_block.module - Implements hook_form_alter().
File
- ./
entityform_block.module, line 88 - Render any entity form into a block.
Code
function entityform_block_submit(&$form, &$form_state) {
$types = array();
$block_exists = FALSE;
$types = variable_get('entityform_block_types', $types);
$type = $form_state['values']['type'];
$original_type = isset($form_state['values']['data']['current_type']) ? $form_state['values']['data']['current_type'] : FALSE;
if (!empty($types)) {
if (isset($original_type)) {
if ($original_type !== $type) {
$entity_name_has_changed = TRUE;
$block_exists = entityform_block_exists($types, $original_type);
}
else {
$block_exists = entityform_block_exists($types, $type);
}
}
}
if ($form_state['values']['data']['enable_block'] == 1) {
$enabled = TRUE;
}
if (isset($enabled)) {
// If the entityform block enabled but doesn't exist add to the array.
if (!$block_exists) {
$types[] = $type;
drupal_set_message(t('Entityform block @title has been created', array(
'@title' => $type,
)));
}
else {
if (isset($entity_name_has_changed)) {
$key = array_search($original_type, $types);
$types[$key] = $type;
entityform_block_change_name($original_type, $type);
}
}
// If it's not enabled but block exists.
}
elseif (!isset($enabled) && $block_exists) {
$key = array_search($original_type, $types);
unset($types[$key]);
drupal_set_message(t('Entityform block @title has been disabled.', array(
'@title' => $type,
)));
}
variable_set('entityform_block_types', $types);
}