function entityform_block_form_alter in Entityform block 7
Implements hook_form_alter().
Adds a checkbox to enable a block to the entity form edit form.
File
- ./
entityform_block.module, line 50 - Render any entity form into a block.
Code
function entityform_block_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'entityform_type_form') {
$types = array();
$types = variable_get('entityform_block_types');
$current_type = $form['#entityform_type']->type;
$form['data']['block_set'] = array(
'#type' => 'fieldset',
'#title' => t('Entity block settings'),
'#collapsible' => TRUE,
'#group' => 'additional_settings',
'#weight' => 100,
);
if (!empty($types) && isset($current_type)) {
$exists = entityform_block_exists($types, $current_type);
if ($exists == TRUE) {
$form['data']['block_set']['current_type'] = array(
'#type' => 'hidden',
'#value' => $current_type,
);
}
}
$form['data']['block_set']['enable_block'] = array(
'#type' => 'checkbox',
'#title' => t('Enable as a block'),
'#description' => t('Create a block with this entity form?'),
'#default_value' => !empty($exists) ? 1 : 0,
);
$form['#submit'][] = 'entityform_block_submit';
}
}