I'm creating a form which I'm showing in a block.
This form contains a date popup field.
I noticed the datepopup javascript is not working when block caching is enabled.
(It only works right after a cache clear.)
Somehow drupal_add_js isn't triggered anymore.
I fixed it by adding
'cache' => DRUPAL_NO_CACHE
to my block.
I couldn't find the real problem..
Code below.
/**
* Implements hook_block_info().
*/
function hotels_block_info() {
$blocks = array();
$blocks['hotels-search'] = array(
'info' => t('Hotels search block'),
//it works if we add the line below
//'cache' => DRUPAL_NO_CACHE,
);
return $blocks;
}
/**
* Implements hook_block_view().
*
* Show a block with a the search form for hotels.
*/
function hotels_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'hotels-search':
$block['subject'] = t('Search & book hotel');
$block['content'] = drupal_get_form('hotels_search_form');
break;
}
return $block;
}
function hotels_search_form($form, &$form_state) {
$form['start'] = array(
'#type' => 'date_popup',
'#label' => '',
'#date_format' => 'd-m-Y',
'#date_label_position' => 'hidden',
'#title' => t("From"),
'#attributes' => array('placeholder' => t("Start date")),
'#required' => TRUE,
'#size' => 20,
'#date_year_range' => '-0:+2',
);
[...]
}
Active
2.6
Date Popup
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.