function ccl_blocks_form_ccl_add_form_alter in Custom Contextual Links 7
Same name and namespace in other branches
- 8 ccl_blocks/ccl_blocks.module \ccl_blocks_form_ccl_add_form_alter()
Implements hook_form_FORM_ID_alter().
Add additional form elements to the main CCL add/edit form.
File
- ccl_blocks/
ccl_blocks.module, line 12 - Implments support for CCL on blocks.
Code
function ccl_blocks_form_ccl_add_form_alter(&$form, &$form_state, $form_id) {
// Check if we are in edit mode.
if (isset($form_state['clid'])) {
$clid = $form_state['clid'];
$link = $form_state['link'];
}
else {
$clid = 0;
}
// Add blocks as an option for links.
$form['options_group']['ccl_type']['#options']['block'] = t('Block');
// Follow the naming conventions outlined here
// in order to avoid naming conflicts.
$form['options_group']['block_global'] = array(
'#type' => 'checkbox',
'#title' => t('Add this link to all blocks'),
'#default_value' => $clid && isset($link->options['block_global']) ? $link->options['block_global'] : -1,
'#states' => array(
'visible' => array(
':input[name="ccl_type"]' => array(
'value' => 'block',
),
),
),
);
$options = _ccl_blocks_get_info();
$form['options_group']['block_select'] = array(
'#type' => 'select',
'#multiple' => TRUE,
'#size' => min(12, count($options)),
'#title' => t('Blocks'),
'#description' => t('Select the block(s) this link should be added to.'),
'#options' => $options,
'#default_value' => $clid && isset($link->options['block_select']) ? $link->options['block_select'] : -1,
'#states' => array(
'visible' => array(
':input[name="block_global"]' => array(
'checked' => FALSE,
),
':input[name="ccl_type"]' => array(
'value' => 'block',
),
),
),
);
// Add validation for blocks.
$form['#validate'][] = "ccl_blocks_validation";
}