I'm new to symfony and have followed this amazing tutorial to setup my bundle and and entitys using the the command line using doctrine via the console.
http://symfony.com/blog/symfony2-getting-easier-interactive-generators
the only issue is that the class I have setup has hidden fields. for example date created and date updated. This is just for my records so I can see if people have been doing things they shouldn't have.
the only issue is they are showing on the front end and I don't know how to hide them, without rewriting the code that was generated and adding the fields one by one.
Here is the function in the controller
public function createAction(Request $request)
{
$entity = new Client();
$form = $this->createCreateForm($entity);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('client_show', array('id' => $entity->getId())));
}
return $this->render('AcmeClientMoodBundle:Client:new.html.twig', array(
'entity' => $entity,
'form' => $form->createView(),
));
}
/**
* Creates a form to create a Client entity.
*
* @param Client $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createCreateForm(Client $entity)
{
$form = $this->createForm(new ClientType(), $entity, array(
'action' => $this->generateUrl('client_create'),
'method' => 'POST',
));
$form->add('submit', 'submit', array('label' => 'Create'));
return $form;
}
and here is the entity/class
namespace Acme\ClientMoodBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* Client
*/
class Client
{
/**
* @var integer
*/
private $id;
/**
* @var string
*/
private $name;
/**
* @var string
*/
private $logo;
/**
* @var integer
*/
private $moodId;
/**
* @var integer
*/
private $projectManagerId;
/**
* @var \DateTime
*/
private $created;
/**
* @var \DateTime
*/
private $updated;
/**
* @var integer
*/
private $active;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return Client
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set logo
*
* @param string $logo
* @return Client
*/
public function setLogo($logo)
{
$this->logo = $logo;
return $this;
}
/**
* Get logo
*
* @return string
*/
public function getLogo()
{
return $this->logo;
}
/**
* Set moodId
*
* @param integer $moodId
* @return Client
*/
public function setMoodId($moodId)
{
$this->moodId = $moodId;
return $this;
}
/**
* Get moodId
*
* @return integer
*/
public function getMoodId()
{
return $this->moodId;
}
/**
* Set projectManagerId
*
* @param integer $projectManagerId
* @return Client
*/
public function setProjectManagerId($projectManagerId)
{
$this->projectManagerId = $projectManagerId;
return $this;
}
/**
* Get projectManagerId
*
* @return integer
*/
public function getProjectManagerId()
{
return $this->projectManagerId;
}
/**
* Set created
*
* @param \DateTime $created
* @return Client
*/
public function setCreated($created)
{
$this->created = $created;
return $this;
}
/**
* Get created
*
* @return \DateTime
*/
public function getCreated()
{
return $this->created;
}
/**
* Set updated
*
* @param \DateTime $updated
* @return Client
*/
public function setUpdated($updated)
{
$this->updated = $updated;
return $this;
}
/**
* Get updated
*
* @return \DateTime
*/
public function getUpdated()
{
return $this->updated;
}
/**
* Set active
*
* @param integer $active
* @return Client
*/
public function setActive($active)
{
$this->active = $active;
return $this;
}
How is the best way to achieve this?