Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
$formMapper->add('duration', 'sonata_type_datetime_picker', [
'label' => 'Продолжительность',
'required' => false,
'format' => 'HH:mm:ss',
'date_format' => 'HH:mm:ss'
])

$('.form-field-time').each(function () {
var el = $(this),
options = {locale: 'ru'};
if (el.data('with-seconds') == 1) {
options.format = 'HH:mm:ss';
} else {
options.format = 'HH:mm';
}
el.datetimepicker(options);
});
Uncaught TypeError: option pickTime is not recognized!
$('#dtp_s5666a539ecb69_duration').datetimepicker({
"pickTime":true,
"useCurrent":true,
"minDate":"1\/1\/1900",
"maxDate":null,
"showToday":true,
"language":"ru",
"defaultDate":"",
"disabledDates":[],
"enabledDates":[],
"icons":{
"time":"fa fa-clock-o",
"date":"fa fa-calendar",
"up":"fa fa-chevron-up",
"down":"fa fa-chevron-down"
},
"useStrict":false,
"sideBySide":false,
"daysOfWeekDisabled":[],
"useMinutes":true,
"useSeconds":true,
"minuteStepping":1
});
public function transform($value)
{
if ($value === null) {
return null;
}
return $value->format($this->options['with_seconds'] ? 'H:i:s' : 'H:i');
}
public function reverseTransform($value)
{
if ($value === null) {
return null;
}
try {
$value = new \DateTime($value);
} catch (\Exception $e) {
throw new TransformationFailedException($e->getMessage());
}
return $value;
}
Внедряем Bootstrap 3 Datepicker в SonataAdminBundle