//Events.php
<?php
namespace erp\GenerateBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* Events
* @ORM\Entity
* @UniqueEntity(fields="description", message="Already Exists")
*/
class Events
{
/**
* @var string
* @Column(type = "string", unique = true)
* @Assert/Description()
*/
private $description;
/**
* @var \DateTime
*/
private $eventdate;
/**
* @var integer
*/
private $duration;
/**
* @var integer
*/
private $createdby;
/**
* @var \DateTime
*/
private $added;
/**
* @var \DateTime
*/
private $updated;
/**
* @var integer
*/
private $id;
/**
* @var \erp\GenerateBundle\Entity\User
*/
private $userid;
/**
* @var \erp\GenerateBundle\Entity\EventType
*/
private $eventtype;
/**
* Set description
*
* @param string $description
* @return Events
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set eventdate
*
* @param \DateTime $eventdate
* @return Events
*/
public function setEventdate($eventdate)
{
$this->eventdate = $eventdate;
return $this;
}
/**
* Get eventdate
*
* @return \DateTime
*/
public function getEventdate()
{
return $this->eventdate;
}
/**
* Set duration
*
* @param integer $duration
* @return Events
*/
public function setDuration($duration)
{
$this->duration = $duration;
return $this;
}
/**
* Get duration
*
* @return integer
*/
public function getDuration()
{
return $this->duration;
}
/**
* Set createdby
*
* @param integer $createdby
* @return Events
*/
public function setCreatedby($createdby)
{
$this->createdby = $createdby;
return $this;
}
/**
* Get createdby
*
* @return integer
*/
public function getCreatedby()
{
return $this->createdby;
}
/**
* Set added
*
* @param \DateTime $added
* @return Events
*/
public function setAdded($added)
{
$this->added = $added;
return $this;
}
/**
* Get added
*
* @return \DateTime
*/
public function getAdded()
{
return $this->added;
}
/**
* Set updated
*
* @param \DateTime $updated
* @return Events
*/
public function setUpdated($updated)
{
$this->updated = $updated;
return $this;
}
/**
* Get updated
*
* @return \DateTime
*/
public function getUpdated()
{
return $this->updated;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set userid
*
* @param \erp\GenerateBundle\Entity\User $userid
* @return Events
*/
public function setUserid(\erp\GenerateBundle\Entity\User $userid = null)
{
$this->userid = $userid;
return $this;
}
/**
* Get userid
*
* @return \erp\GenerateBundle\Entity\User
*/
public function getUserid()
{
return $this->userid;
}
/**
* Set eventtype
*
* @param \erp\GenerateBundle\Entity\EventType $eventtype
* @return Events
*/
public function setEventtype(\erp\GenerateBundle\Entity\EventType $eventtype = null)
{
$this->eventtype = $eventtype;
return $this;
}
/**
* Get eventtype
*
* @return \erp\GenerateBundle\Entity\EventType
*/
public function getEventtype()
{
return $this->eventtype;
}
}
答案 0 :(得分:0)
检查Config.yml
框架: 验证:{enabled:true,enable_annotations:true}
在控制器中 检查isValid() 如果它不存在那么添加。提交表格之前的isValid()。
答案 1 :(得分:0)
我很难解读你的问题。有错误消息吗?持久存在数据库或提交表单的问题在哪里?
但我发现你发布的代码存在一些问题。
@Assert/Description()
不存在。use Doctrine\ORM\Mapping as ORM;
@ORM\Column(type = "string", unique = true)
@Column
醇>