| @@ 13-46 (lines=34) @@ | ||
| 10 | use Psi\Component\ContentType\Standard\View; |
|
| 11 | use Symfony\Component\Form\Extension\Core\Type as Form; |
|
| 12 | ||
| 13 | class DateField implements FieldInterface |
|
| 14 | { |
|
| 15 | public function getViewType(): string |
|
| 16 | { |
|
| 17 | return View\DateTimeType::class; |
|
| 18 | } |
|
| 19 | ||
| 20 | public function getFormType(): string |
|
| 21 | { |
|
| 22 | return Form\DateType::class; |
|
| 23 | } |
|
| 24 | ||
| 25 | public function getStorageType(): string |
|
| 26 | { |
|
| 27 | return Storage\DateTimeType::class; |
|
| 28 | } |
|
| 29 | ||
| 30 | public function configureOptions(FieldOptionsResolver $options) |
|
| 31 | { |
|
| 32 | $options->setFormMapper(function ($options, $shared) { |
|
| 33 | $options['input'] = 'datetime'; |
|
| 34 | ||
| 35 | return $options; |
|
| 36 | }); |
|
| 37 | ||
| 38 | $options->setViewMapper(function ($options, $shared) { |
|
| 39 | $options = array_merge([ |
|
| 40 | 'time_format' => 'none' |
|
| 41 | ], $options); |
|
| 42 | ||
| 43 | return $options; |
|
| 44 | }); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| @@ 13-46 (lines=34) @@ | ||
| 10 | use Psi\Component\ContentType\Standard\View; |
|
| 11 | use Symfony\Component\Form\Extension\Core\Type as Form; |
|
| 12 | ||
| 13 | class TimeField implements FieldInterface |
|
| 14 | { |
|
| 15 | public function getViewType(): string |
|
| 16 | { |
|
| 17 | return View\DateTimeType::class; |
|
| 18 | } |
|
| 19 | ||
| 20 | public function getFormType(): string |
|
| 21 | { |
|
| 22 | return Form\TimeType::class; |
|
| 23 | } |
|
| 24 | ||
| 25 | public function getStorageType(): string |
|
| 26 | { |
|
| 27 | return Storage\DateTimeType::class; |
|
| 28 | } |
|
| 29 | ||
| 30 | public function configureOptions(FieldOptionsResolver $options) |
|
| 31 | { |
|
| 32 | $options->setFormMapper(function ($options, $shared) { |
|
| 33 | $options['input'] = 'datetime'; |
|
| 34 | ||
| 35 | return $options; |
|
| 36 | }); |
|
| 37 | ||
| 38 | $options->setViewMapper(function ($options, $shared) { |
|
| 39 | $options = array_merge([ |
|
| 40 | 'date_format' => 'none' |
|
| 41 | ], $options); |
|
| 42 | ||
| 43 | return $options; |
|
| 44 | }); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||