0

I want to include a datepicker in my form. I find this :

twig:
debug:            "%kernel.debug%"
strict_variables: "%kernel.debug%"
form_themes: 
    resources :
       - 'SonataCoreBundle::Form:datepicker.html.twig'

but when I clear the cache i have this message :

[Symfony\Component\Config\Definition\Exception\InvalidTypeException]
Invalid type for path "twig.form_themes.resources". Expected scalar, but got array

I dont understand. Can you explain me please. Thank you

loustalet
  • 72
  • 1
  • 9
  • Try with this answer: http://stackoverflow.com/questions/14443558/sonata-admin-bundle-datepicker-range?answertab=votes#tab-top Remove "resources" path. – panche14 Nov 23 '16 at 11:34

2 Answers2

1

Just delete resources : in your twig configuration.

Look this

twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"
    form_themes:                 
        - 'SonataCoreBundle::Form:datepicker.html.twig'
Emaus
  • 125
  • 9
0

You can use this example configuration for form type.

$formMapper->add(
        'createdAt',
        DateTimePickerType::class,
        [
            'label'             => 'Data utworzenia',
            'attr'              => ['style' => 'width:300px;'],
            'dp_side_by_side'   => true,
            'dp_use_current'    => false,
            'dp_use_seconds'    => false,
            'dp_collapse'       => true,
            'dp_calendar_weeks' => false,
            'dp_view_mode'      => 'days',
            'dp_min_view_mode'  => 'days',
            'format'            => 'yyyy-MM-dd HH:mm',
        ]
    );

This is working example, for SF 4.x

deyvw
  • 820
  • 7
  • 9