function fe_block_form_alter in Features Extra 6
Same name and namespace in other branches
- 7 fe_block/fe_block.module \fe_block_form_alter()
Implementation of hook_form_alter().
File
- ./
fe_block.module, line 328
Code
function fe_block_form_alter(&$form, $form_state, $form_id) {
$default_values = array();
if ($form_id == 'block_add_block_form' && $form['module']['#value'] == 'block' && user_access('administer features')) {
$default_values['machine_name'] = '';
$default_values['bid'] = 0;
}
elseif ($form_id == 'block_admin_configure' && $form['module']['#value'] == 'block' && user_access('administer features')) {
$bid = $form['delta']['#value'];
$machine_name = _fe_block_get_machine_name($bid);
$default_values['machine_name'] = empty($machine_name) ? '' : $machine_name;
$default_values['bid'] = $bid;
}
elseif ($form_id == 'block_box_delete') {
$form['#submit'][] = 'fe_block_machine_name_delete';
}
// Add & edit
if (!empty($default_values)) {
$form['block_settings']['machine_name'] = array(
'#type' => 'textfield',
'#title' => t('Machine name'),
'#default_value' => $default_values['machine_name'],
'#maxlength' => 32,
'#description' => t('Give the block a machine name to make it exportable with "!features" module.', array(
'!features' => l('Features', 'http://drupal.org/project/features'),
)),
'#weight' => -20,
);
$form['bid'] = array(
'#type' => 'value',
'#value' => $default_values['bid'],
);
// Validate & submit.
$form['#validate'][] = 'fe_block_machine_name_validate';
$form['#submit'][] = 'fe_block_machine_name_submit';
}
}