开发者

Drupal 7 date_popup timepicker only default value

开发者 https://www.devze.com 2023-03-19 16:26 出处:网络
I am currently using Drupal 7\'s date_popup. One of the problems I encountered was the default value not appearing if I\'ve only selected the format as time-only.

I am currently using Drupal 7's date_popup. One of the problems I encountered was the default value not appearing if I've only selected the format as time-only.

I.e.

    $form['start'] = array(
            '#type' => 'date_popup',
            '#title' => t('Start'),
            '#default_value' => date("Y-m-d H:i:s", $start), 
            '#date_format' => "Y-m-d h:i A",
    );

shows the correct default value, although it includes all the date stuff (I only want a timepicker actually). But if I change '#date_format' to a time-only format, i.e. this:

    $form['start'] = array(
            '#type' => 'date_popup',
            '#title' => t('Start'),
            '#default_value' => date("Y-m-d H:i:s", $start), 
            '#date_format' => "h:i A",
    );

There is no more default value. How can I have a default value开发者_运维知识库 for date_popup for a time-only format?


There's a patch for the date popup module here which might be suitable

http://drupal.org/node/1037150

But it would appear that it's a bug introduced while adding relative functionality to time only fields.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号