您的实体/项目中是否有任何验证器文件或规则?
您是否还尝试将表单选项(通过 addFormOption 键)“必需”设置为 false?
=== 编辑
我刚刚创建了以下示例应用程序:
generator: admingenerator.generator.doctrine
params:
model: Application\CoreBundle\Entity\Account
namespace_prefix: Application
concurrency_lock: ~
bundle_name: AdminBundle
pk_requirement: ~
fields:
id:
filterable: 1
name:
filterable: 1
expirationDate:
formType: s2a_date_picker
object_actions:
delete: ~
batch_actions:
delete: ~
builders:
list:
params:
title: List for AdminBundle
display: ~
filters: ~
actions:
new: ~
object_actions:
edit: ~
delete: ~
excel:
params: ~
filename: ~
filetype: ~
new:
params:
title: New object for AdminBundle
display:
- name
- expirationDate
actions:
save: ~
list: ~
edit:
params:
title: "You're editing the object \"%object%\"|{ %object%: Account.name }|"
display:
- name
- expirationDate
actions:
save: ~
list: ~
show:
params:
title: "You're viewing the object \"%object%\"|{ %object%: Account.name }|"
display: ~
actions:
list: ~
new: ~
actions:
params:
object_actions:
delete: ~
batch_actions:
delete: ~
使用此实体映射:
Application\CoreBundle\Entity\Account:
type: entity
table: null
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
name:
type: string
length: 255
expirationDate:
type: datetime
nullable: true
lifecycleCallbacks: { }
当然,以防万一,实体:
<?php
namespace Application\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Account
*/
class Account
{
/**
* @var integer
*/
private $id;
/**
* @var string
*/
private $name;
/**
* @var \DateTime
*/
private $expirationDate = null;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return Account
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param \DateTime $expirationDate
* @return $this
*/
public function setExpirationDate(\DateTime $expirationDate = null)
{
$this->expirationDate = $expirationDate;
return $this;
}
/**
* @return \DateTime
*/
public function getExpirationDate()
{
return $this->expirationDate;
}
}
并且我的实体上没有特定的自定义,也没有我的管理员配置或其他任何东西......而且效果很好。
它对你有帮助吗?你在你的应用程序中做一些特定的事情吗?