时间选择器未出现在SilverStripe中

时间:2016-02-01 12:39:08

标签: php jquery datetimepicker silverstripe

mysite / code / EventManage.php
在这里,我正在创建一个时间选择器,但日期选择器弹出窗口没有出现。

$fields = FieldList::create(
$startDateTime = DatetimeField::create('StartDateTime', 'Start'),
HeaderField::create('TimeFrameHeader', $timeFrameHeaderText, 5),
SelectionGroup::create('TimeFrameType', array(
    "Duration//Duration" => TimeField::create('Duration', '')->setRightTitle('up to 24h')
        ->setAttribute('placeholder','Enter duration'), 
    "DateTime//Date/Time" => $endDateTime = DateTimeField::create('EndDateTime', '')
    )
),
);

$startDateTime->getTimeField()
->setConfig('timeformat', 'HH:mm') //24h format
->setAttribute('placeholder','Enter time')
->setAttribute('readonly', 'true'); //we only want input through the timepicker

2 个答案:

答案 0 :(得分:3)

安装timepickerfield模块

https://github.com/sheadawson/silverstripe-timepickerfield

然后:

TimePickerField::create('Duration')
...

对于你的DateTimeField:

$startDateTime->setTimeField(TimePickerField::create('StartDateTime'))
...

答案 1 :(得分:0)

我想知道你是否可以显示TimeField的下拉列表?

对于DateField,有setConfig('showcalendar', true)选项。

我发现这个silverstripe-timedropdownfield可能是您正在寻找的解决方案。