I am using Sonata Admin with some fields of the type DateTime
and I want to use sonata_type_datetime_picker
as described here. This worked very well a few days ago, but now it stopped working and I have no idea, why. Spend nearly a day on this now with no progress.
twig.yml
:
twig:
debug: '%kernel.debug%'
form_themes:
- 'SonataCoreBundle:Form:datepicker.html.twig'
strict_variables: '%kernel.debug%'
Usage in my admin class:
->add(
'creationDate',
'sonata_type_datetime_picker',
[
'required' => false
]
)
But it is rendered like this (so I think the form_theme
is not loaded at all since it kinda fallbacks to sonata-ba-field-standard-natural
?)
<div class="form-group" id="sonata-ba-field-container-s59c611aaec3a3_creationDate">
<label class=" control-label" for="s59c611aaec3a3_creationDate">
Erstelldatum
</label>
<div class="sonata-ba-field sonata-ba-field-standard-natural">
<input type="text" id="s59c611aaec3a3_creationDate" name="s59c611aaec3a3[creationDate]" class="sonata-medium-date form-control" value="20.09.2017, 15:41:43">
</div>
</div>
My twig.yml
is definitely loaded since it crashes when I add some errors. But when I modify datepicker.html.twig
directly in the vendor folder by misspelling some twig code, nothing crashes - even when I delete the cache folder by myself.
Does anyone have a clue what possibly could be wrong or where I could start to dig even deeper? Bundle versions:
"php": "7.0.*",
"symfony/symfony": "3.3.*",
"api-platform/core": "^2.0",
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"symfony/swiftmailer-bundle": "^2.3",
"symfony/monolog-bundle": "^3.0",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "^2.0",
"dunglas/action-bundle": "^0.3",
"nelmio/cors-bundle": "^1.4",
"phpdocumentor/reflection-docblock": "^3.0",
"sonata-project/admin-bundle": "^3.21",
"sonata-project/doctrine-orm-admin-bundle": "^3.1",
"friendsofsymfony/user-bundle": "~2.0",
"doctrine/data-fixtures": "^1.2",
"nelmio/api-doc-bundle": "^2.11.2",
"sonata-project/intl-bundle": "^2.3",
"knplabs/knp-gaufrette-bundle": "~0.4",
"sonata-project/user-bundle": "dev-add_support_for_fos_user2"
Update: Does also not work with symfony 3.2:
"php": "7.0.*",
"symfony/symfony": "3.2.*",
"api-platform/core": "^2.0",
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"symfony/swiftmailer-bundle": "^2.3",
"symfony/monolog-bundle": "^3.0",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "^2.0",
"dunglas/action-bundle": "^0.3",
"nelmio/cors-bundle": "^1.4",
"phpdocumentor/reflection-docblock": "^3.0",
"sonata-project/admin-bundle": "^3.21",
"sonata-project/doctrine-orm-admin-bundle": "^3.1",
"friendsofsymfony/user-bundle": "~2.0",
"doctrine/data-fixtures": "^1.2",
"nelmio/api-doc-bundle": "^2.11.2",
"sonata-project/intl-bundle": "^2.3",
"knplabs/knp-gaufrette-bundle": "~0.4",
"sonata-project/user-bundle": "dev-add_support_for_fos_user2"
Ok, I found the issue. For some reason, SonataUserBundle
requires the (obsolete?) parameter twig.form.resources
. So I just added twig.form.resources: []
into my parameters.yml
to workaround this.
But for some reason, this completely overwrote my twig configuration:
twig:
form_themes:
- 'SonataCoreBundle:Form:datepicker.html.twig'
So as a workaround, I now do also this:
twig.form.resources: ['SonataCoreBundle:Form:datepicker.html.twig']