简体   繁体   English

新奏鸣曲页面捆绑网站上的“启用自”无效

[英]"Enabled from" on a new Sonata Page Bundle site is invalid

I have a brand-new installation of Sonata Page Bundle.我有一个全新的 Sonata Page Bundle 安装。 I am creating a Site entity using the Site admin screen.我正在使用站点管理屏幕创建站点实体。

I use the DateTimePicker that comes with the bundle to choose the "enabled from" date.我使用捆绑包附带的 DateTimePicker 来选择“启用日期”。 The picker creates this date: May 27, 2021, 6:40:43 pm选择器创建此日期: May 27, 2021, 6:40:43 pm

I then save the page.然后我保存页面。 The validator tells me that "This value is not valid."验证器告诉我“这个值无效”。 On a string that the same page's picker generated!在同一页面的选择器生成的字符串上!

Is this a known bug?这是一个已知的错误? Or am I doing something wrong?还是我做错了什么? I would just leave this blank, but the field is mandatory.我会把这个留空,但该字段是强制性的。

For reference, composer says I have page-bundle version 3.22.2, which packagist says is the newest stable version.作为参考,composer 说我有 page-bundle 版本 3.22.2,packagist 说这是最新的稳定版本。 The version for admin-bundle is 3.100.2. admin-bundle 的版本是 3.100.2。

Also for reference: My Firefox browser is set to use American English as its language, in case that's relevant.另供参考:我的 Firefox 浏览器设置为使用美式英语作为其语言,以防万一。

I installed a symfony (v4.4.25) + sonata project with PHP 7.4.2 to reproduce this and I didn't have this error, my browser is in english too.我用 PHP 7.4.2 安装了 symfony (v4.4.25) + 奏鸣曲项目来重现这个,我没有这个错误,我的浏览器也是英文的。

在此处输入图像描述

在此处输入图像描述

You should verify if you have moment.min.js or any javascript missing.您应该验证是否缺少 moment.min.js 或任何 javascript。 The javascript should change the date format to a database friendly format, mysql for me, on submit event. javascript 应该在提交事件时将日期格式更改为数据库友好格式,对我来说 mysql。

在此处输入图像描述

After installing the sonata bundles with the recipes (to avoid doing all the configuration manually), I added to sonata_admin.yaml在使用配方安装奏鸣曲捆绑包后(以避免手动进行所有配置),我添加到 sonata_admin.yaml

   assets:
        extra_javascripts:
            - bundles/sonatapage/sonata-page.back.min.js
        extra_stylesheets:
            - bundles/sonatapage/sonata-page.back.min.css

I had the following error on /admin/app/sonatapagesite/1/edit我在 /admin/app/sonatapagesite/1/edit 上有以下错误

Too few arguments to function Sonata\Form\Type\BasePickerType::__construct(), 0 passed in /Users/hyper/Work/Stackoverflow/so/vendor/symfony/form/FormRegistry.php on line 91 and exactly 3 expected

To fix it, I added to bundles.php为了修复它,我添加到 bundles.php

Sonata\Form\Bridge\Symfony\SonataFormBundle::class => ['all' => true],

It looks like the validator is doing something wrong, as it expects a different format (probably yyyy-mm-dd).看起来验证器做错了什么,因为它需要不同的格式(可能是 yyyy-mm-dd)。

I found an answer made by @Capfer to a similar question that may be useful.我找到了@Capfer 对可能有用的类似问题的回答。 He basically changes the expected date format of the form type.他基本上改变了表单类型的预期日期格式。

Link 关联

$formMapper
->add('dateOfAdoption', 'sonata_type_datetime_picker',
     [
        'dp_default_date' => $container->getCreatedAt()->format('d M. Y H:i '),
        'datepicker_use_button' => true,
        'mapped' => false,
     ]
);

Note: 
d - The day of the month (from 01 to 31)
M - A short textual representation of a month (three letters)
Y - A four digit representation of a year
H - 24-hour format of an hour (00 to 23)
i - Minutes with leading zeros (00 to 59)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM