简体   繁体   English

Symfony2-SonataAdmin-“添加新内容”时保留日期时间

[英]Symfony2 - SonataAdmin - Keep datetime when “Add new”

I am designing a blog using Sonata Admin Bundle. 我正在使用Sonata Admin Bundle设计博客。 The entity "News" is very simple (title, subtitle, content, creation date). “新闻”实体非常简单(标题,字幕,内容,创建日期)。 I have a unique need. 我有一个独特的需求。

The creation date should not be taken when I click on "Create", but when I click on "Add new". 当我单击“创建”时,不应选择创建日期,而应单击“添加新”。 In other words, I take the current datetime when I open the page with the form to create, not when I click on "Create". 换句话说,当我打开带有要创建的表单的页面时,而不是单击“创建”时,我将采用当前日期时间。

How can I solve this problem? 我怎么解决这个问题?

Thank you all! 谢谢你们!

您可以在管理方法configureFormFields中为日期表单字段将新的DateTime设置为参数“ data”。

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

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