"sonata_type_datetime_picker" 的表单主题未加载到 sonata admin 中

Form theme for "sonata_type_datetime_picker" not loaded in sonata admin

我正在将 Sonata Admin 与 DateTime 类型的某些字段一起使用,我想按照 here 所述使用 sonata_type_datetime_picker。几天前效果很好,但现在它停止工作了,我不知道为什么。现在花了将近一天的时间没有任何进展。

twig.yml:

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

我的管理员中的用法class:

->add(
    'creationDate',
    'sonata_type_datetime_picker',
    [
        'required' => false
    ]
)

但它是这样呈现的(所以我认为 form_theme 根本没有加载,因为它有点回退到 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>

我的 twig.yml 确实已加载,因为当我添加一些错误时它崩溃了。但是当我通过拼写错误的一些树枝代码直接在供应商文件夹中修改 datepicker.html.twig 时,没有任何崩溃 - 即使我自己删除了缓存文件夹。

有没有人知道什么可能是错误的或者我可以从哪里开始更深入地挖掘?捆绑包版本:

"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"

更新:也不适用于 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"

好的,我找到问题了。出于某种原因,SonataUserBundle 需要(过时的?)参数 twig.form.resources。所以我只是将 twig.form.resources: [] 添加到我的 parameters.yml 中来解决这个问题。

但出于某种原因,这完全覆盖了我的树枝配置:

twig:
    form_themes:
        - 'SonataCoreBundle:Form:datepicker.html.twig'

因此,作为解决方法,我现在也这样做:

twig.form.resources: ['SonataCoreBundle:Form:datepicker.html.twig']