function formblock_form_alter in Form Block 7
Same name and namespace in other branches
- 5 formblock.module \formblock_form_alter()
- 6 formblock.module \formblock_form_alter()
Implements hook_form_alter().
File
- ./
formblock.module, line 6
Code
function formblock_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'node_type_form' && isset($form['#node_type']->type)) {
$form['formblock'] = array(
'#type' => 'fieldset',
'#title' => t('Form block'),
'#group' => 'additional_settings',
'#attributes' => array(
'class' => array(
'formblock-node-type-settings-form',
),
),
'#attached' => array(
'js' => array(
drupal_get_path('module', 'formblock') . '/formblock.js',
),
),
);
$form['formblock']['formblock_expose'] = array(
'#type' => 'checkbox',
'#title' => t('Enable data entry from a block'),
'#default_value' => variable_get('formblock_expose_' . $form['#node_type']->type, 0),
'#description' => t('Enable this option to make the entry form for this content type available as a block.'),
);
$form['formblock']['formblock_show_help'] = array(
'#type' => 'checkbox',
'#title' => t('Show submission guidelines'),
'#default_value' => variable_get('formblock_show_help_' . $form['#node_type']->type, 0),
'#description' => t('Enable this option to show the submission guidelines in the block above the form.'),
'#states' => array(
'visible' => array(
':input[name="formblock_expose"]' => array(
'checked' => TRUE,
),
),
),
);
}
elseif (strpos($form_id, '_node_form') !== FALSE) {
// Make sure we have necessary includes.
if (empty($form_state['build_info']['files']) || !in_array('modules/node/node.pages.inc', $form_state['build_info']['files'])) {
form_load_include($form_state, 'inc', 'node', 'node.pages');
}
}
}