I have used CRUD to generate actions for an entity. However, I would like to modify the edit action; for instance, a user select 'inactive' represented by 1 for State then they will be shown an error message otherwise they can proceed to updating that row. Within the entity these are the variables state, paypid, startDate, endDate.
This is what the edit action currently looks like.
public function editAction($Paypid)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('comtwclagripayrollBundle:Payrollperiod')->find($Paypid);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Payrollperiod entity.');
}
$editForm = $this->createEditForm($entity);
$deleteForm = $this->createDeleteForm($Paypid);
return array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
This is the payroll period entity
namespace com\twcl\agripayrollBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert;
/** * Payrollperiod * @ORM\Entity(repositoryClass="com\twcl\agripayrollBundle\Entity\PayPeriodRepository") * * */ class Payrollperiod { /** * @var \DateTime */ private $startdate;
/**
* @var \DateTime
*/
private $enddate;
/**
* @var integer
*/
private $state;
/**
* @var integer
*/
private $paypid;
/**
* Set startdate
*
* @param \DateTime $startdate
* @return Payrollperiod
*/
public function setStartdate($startdate)
{
$this->startdate = $startdate;
return $this;
}
/**
* Get startdate
*
* @return \DateTime
*/
public function getStartdate()
{
return $this->startdate;
}
/**
* Set enddate
*
* @param \DateTime $enddate
* @return Payrollperiod
*/
public function setEnddate($enddate)
{
$this->enddate = $enddate;
return $this;
}
/**
* Get enddate
*
* @return \DateTime
*/
public function getEnddate()
{
return $this->enddate;
}
/**
* Set state
*
* @param integer $state
* @return Payrollperiod
*/
public function setState($state)
{
$this->state = $state;
return $this;
}
/**
* Get state
*
* @return integer
*/
public function getState()
{
return $this->state;
}
/**
* Get paypid
*
* @return integer
*/
public function getPaypid()
{
return $this->paypid;
}
public function setPayid($payid){
$this->paypid = $payid;
} /** * Render a payrollPeriodID as a string. * * @return string */
public function __toString()
{
return (string) $this->getstartDate()->format('d-M-y').'/'.$this->getendDate()->format('d-M-y');
}
public function __construct()
{
$this->PayrollperiodType = new \Doctrine\Common\Collection\ArrayCollection();
}
}
Can someone assist me with this issue?