表格主题为" sonata_type_datetime_picker"未装入奏鸣曲管理员

时间:2017-09-23 07:53:37

标签: datepicker twig sonata-admin symfony-3.3

我正在使用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%'

我的管理类中的用法:

->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肯定已加载,因为当我添加一些错误时它会崩溃。但是当我通过拼错一些twig代码直接修改供应商文件夹中的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"

1 个答案:

答案 0 :(得分:2)

好的,我发现了这个问题。出于某种原因,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']