为什么Symfony sonata_type_date_picker用西班牙语的9月返回无效值

时间:2018-09-26 14:22:59

标签: symfony validation datepicker sonata

这是一个奇怪的问题。但是,当我将每年的任何一天与9月作为一个月发送时,都没有得到日期。

$ composer show --latest 'sonata-project/*'

sonata-project/admin-bundle              3.35.2 3.39.0 The missing Symfony Admin Generator
sonata-project/block-bundle              3.12.1 3.12.1 Symfony SonataBlockBundle
sonata-project/cache                     2.0.1  2.0.1  Cache library
sonata-project/core-bundle               3.11.1 3.11.2 Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.3.1  2.3.1  Symfony SonataDatagridBundle
sonata-project/doctrine-orm-admin-bundle 3.6.1  3.6.1  Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/exporter                  1.9.0  1.9.1  Lightweight Exporter library
sonata-project/intl-bundle               2.4.1  2.5.0  Symfony SonataIntlBundle
sonata-project/translation-bundle        2.3.0  2.3.1  SonataTranslationBundle

Symfony软件包

$ composer show --latest 'symfony/*'

symfony/monolog-bundle     v3.3.0  v3.3.0 Symfony MonologBundle
symfony/phpunit-bridge     v3.4.11 v4.1.4 Symfony PHPUnit Bridge
symfony/polyfill-apcu      v1.8.0  v1.9.0 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-ctype     v1.8.0  v1.9.0 Symfony polyfill for ctype functions
symfony/polyfill-intl-icu  v1.8.0  v1.9.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring  v1.8.0  v1.9.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php56     v1.8.0  v1.9.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70     v1.8.0  v1.9.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util      v1.8.0  v1.9.0 Symfony utilities for portability of PHP codes
symfony/security-acl       v3.0.1  v3.0.1 Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle v2.6.7  v3.2.3 Symfony SwiftmailerBundle
symfony/symfony            v3.4.11 v4.1.4 The Symfony PHP framework
PHP版本
$ php -v

PHP 7.1.20-1+0~20180910100532.3+stretch~1.gbp17c613 (cli) (built: Sep 10 2018 10:05:33) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.20-1+0~20180910100532.3+stretch~1.gbp17c613, Copyright (c) 1999-2018, by Zend Technologies

我正在使用Sonata admin,并使用以下命令设置了配置文件:

sonata_intl:
  timezone:
    default: America/Argentina/Ushuaia

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

ajax呼叫正在发送此消息:

s5bab8a989fa81[fechaDesde]:26 sep. 2018
s5bab8a989fa81[fechaHasta]:27 oct. 2018
s5bab8a989fa81[fechaFinProhibicion]:1 dic. 2018

如果我在validate hook中捕获了日期,则返回以下内容:

FechaDesde :
FechaHasta :DateTime Object ( [date] => 2018-10-26 23:00:00.000000 [timezone_type] => 3 [timezone] => America/Sao_Paulo ) 
FechaFinProhibicion :DateTime Object ( [date] => 2018-12-01 00:00:00.000000 [timezone_type] => 3 [timezone] => America/Sao_Paulo )

有什么主意吗? 谢谢


更新

使用'format' => \IntlDateFormatter::LONG解决了我的问题,但是'format' => \IntlDateFormatter::MEDIUM无法正常工作

0 个答案:

没有答案