function bootstrap_field_image_widget_carousel_process in Bootstrap Core 7.3
A callback for #process.
Expands the image_image type to include the Bootstrap Carousel fields.
1 string reference to 'bootstrap_field_image_widget_carousel_process'
- bootstrap_field_field_widget_form_alter in bootstrap_field/
bootstrap_field.module - Implements hook_field_widget_form_alter().
File
- bootstrap_field/
includes/ carousel.inc, line 133 - carousel.inc
Code
function bootstrap_field_image_widget_carousel_process($element, &$form_state, $form) {
$fid = isset($element['#value']['fid']) ? (int) $element['#value']['fid'] : 0;
// Retrieve the database settings for this Bootstrap Carousel image.
$conditions = array(
'entity_type' => $element['#entity_type'],
'entity_bundle' => $element['#bundle'],
'entity' => $element['#entity'],
);
$carousel = bootstrap_field_load_carousel($fid, $conditions);
$element['bootstrap_carousel'] = array(
'#access' => (bool) $fid,
'#type' => 'fieldset',
'#title' => t('Slide settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#tree' => TRUE,
);
// Add the additional Bootstrap Carousel fields.
$element['bootstrap_carousel']['title'] = array(
'#title' => t('Title'),
'#type' => 'textfield',
'#default_value' => $carousel[$fid]->settings['title'],
'#description' => t('This text will be used as the slide title.'),
'#maxlength' => 512,
'#attributes' => array(
'class' => array(
'input-sm',
),
),
);
$element['bootstrap_carousel']['description'] = array(
'#type' => 'text_format',
'#title' => t('Description'),
'#description' => t('This text will be used as the slide description.'),
'#attributes' => array(
'class' => array(
'input-sm',
),
),
);
if (isset($carousel[$fid]->settings['description']['value'])) {
$element['bootstrap_carousel']['description']['#default_value'] = $carousel[$fid]->settings['description']['value'];
}
if (isset($carousel[$fid]->settings['description']['format'])) {
$element['bootstrap_carousel']['description']['#format'] = $carousel[$fid]->settings['description']['format'];
}
$element['bootstrap_carousel']['url'] = array(
'#title' => t('URL'),
'#type' => 'textfield',
'#default_value' => $carousel[$fid]->settings['url'],
'#description' => t('This text will be used as the URL to wrap the slide image with a link. It may be an internal path (i.e %node) or an absolute url (i.e. %url). If this is an internal path, it will be subject to permission checks. If a user does not have access, the link will not show.', array(
'%node' => 'node/1',
'%url' => 'http://www.example.com',
)),
'#maxlength' => 1024,
'#element_validate' => array(
'bootstrap_field_image_widget_carousel_url_validate',
),
'#attributes' => array(
'class' => array(
'input-sm',
),
),
);
$element['bootstrap_carousel']['url_new_window'] = array(
'#title' => t('Open URL in new window'),
'#type' => 'checkbox',
'#default_value' => $carousel[$fid]->settings['url_new_window'],
'#states' => array(
'invisible' => array(
':input[name="' . $element['#name'] . '[bootstrap_carousel][url]"]' => array(
'value' => '',
),
),
),
);
return $element;
}