function parallax_block_form_alter in Parallax Toolkit 7.2
Same name and namespace in other branches
- 7.3 parallax_block/parallax_block.module \parallax_block_form_alter()
Implements hook_form_alter().
File
- parallax_block/
parallax_block.module, line 69 - Enable Parallax effect for any block created by the user.
Code
function parallax_block_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'block_admin_configure' || $form_id == 'block_add_block_form') {
$block = block_load($form['module']['#value'], $form['delta']['#value']);
$form['settings']['parallax'] = array(
'#type' => 'fieldset',
'#title' => t('Parallax Settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['settings']['parallax']['vertical_parallax_value'] = array(
'#title' => t('Vertical Parallax Direction'),
'#type' => 'select',
'#options' => array(
'none' => t('None'),
'top-to-bottom' => t('Move to bottom on scroll (fast effect)'),
'bottom-to-top' => t('Move to top on scroll (slow effect)'),
),
'#default_value' => isset($block->vertical_parallax_value) ? $block->vertical_parallax_value : 'none',
);
$form['settings']['parallax']['horizontal_parallax_value'] = array(
'#title' => t('Horizontal Parallax Direction'),
'#type' => 'select',
'#options' => array(
'none' => t('None'),
'left-to-right' => t('Move to left on scroll'),
'right-to-left' => t('Move to right on scroll'),
),
'#default_value' => isset($block->horizontal_parallax_value) ? $block->horizontal_parallax_value : 'none',
);
$form['settings']['parallax']['background_image'] = array(
'#title' => t('Background Image'),
'#type' => 'managed_file',
'#description' => t('Replace all spaces in file name with dashes. Larger pictures are recommended.'),
'#default_value' => isset($block->background_image) ? $block->background_image : '',
'#upload_location' => 'public://parallax_block/',
'#upload_validators' => array(
'file_validate_extensions' => array(
'gif png jpg jpeg',
),
'file_validate_size' => array(
2 * 1024 * 1024,
),
),
);
$form['settings']['parallax']['background_size'] = array(
'#title' => t('Background Size'),
'#type' => 'textfield',
'#size' => 60,
'#default_value' => isset($block->background_size) ? $block->background_size : 'none',
'#description' => t('Acceptable values are none, cover, contain, or percentages/pixels in the form of "200px" and "200%". If there is no effect, try altering this value.'),
'#maxlength' => 20,
'#required' => TRUE,
'#element_validate' => array(
'parallax_block_validate_size',
),
);
$form['#submit'][] = 'parallax_block_form_submit';
}
}