Time Picker does not appear in SilverStripe

mysite / code / EventManage.php
Here I create a time collector, but the date picker does not appear.

$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
+4
source share
2 answers

Install timepickerfield module

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

Then:

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

And for your DateTimeField:

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

Interestingly, you can even show a drop down menu for TimeField?

There DateFieldis an option for a setConfig('showcalendar', true).

I found this silverstripe-timedropdownfield , which may be the solution you are looking for.

0
source

Source: https://habr.com/ru/post/1626854/


All Articles