时间选择器未出现在 SilverStripe 中
Time Picker does not appears in 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
我想知道你是否可以显示 TimeField
的下拉菜单?
对于 DateField
有 setConfig('showcalendar', true)
选项。
我找到了这个 silverstripe-timedropdownfield,这可能是您正在寻找的解决方案。
安装timepickerfield模块
https://github.com/sheadawson/silverstripe-timepickerfield
然后:
TimePickerField::create('Duration')
...
对于您的 DateTimeField:
$startDateTime->setTimeField(TimePickerField::create('StartDateTime'))
...
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
我想知道你是否可以显示 TimeField
的下拉菜单?
对于 DateField
有 setConfig('showcalendar', true)
选项。
我找到了这个 silverstripe-timedropdownfield,这可能是您正在寻找的解决方案。
安装timepickerfield模块
https://github.com/sheadawson/silverstripe-timepickerfield
然后:
TimePickerField::create('Duration')
...
对于您的 DateTimeField:
$startDateTime->setTimeField(TimePickerField::create('StartDateTime'))
...