Note that there are some explanatory texts on larger screens.

plurals
  1. POSave singup date whitout hidden field in Symfony2
    primarykey
    data
    text
    <p>First of all thank you for reading and trying to help me. I'm new in symfony.</p> <p>I have an entity with property FechaAlta (SingUpDate). I want to save the user sing up date</p> <pre><code>/** * @var date * * @ORM\Column(name="fechaAlta", type="datetime") */ private $fechaAlta; /** * Set fechaAlta * * @return Promotor */ public function setFechaAlta() { $this-&gt;fechaAlta = new \DateTime('now'); return $this; } </code></pre> <p>I'd like to know what is the best way to save this date without having a hidden field on the form.</p> <pre><code>public function buildForm(FormBuilderInterface $builder, array $options) { $builder -&gt;add('nombre') #-&gt;add('slug') -&gt;add('fechaAlta') ; } </code></pre> <p>I have tried removing the form field "fechaAlta" but keep get the following error</p> <pre><code>An exception occurred while executing 'INSERT INTO Promotor (nombre, slug, fechaAlta) VALUES (?, ?, ?)' with params {"1":"Prueba","2":"prueba","3":null}: </code></pre> <p>SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'fechaAlta' cannot be null</p> <p>In the newAction() i call $promotor->setFechaAlta(); that should save the current date.</p> <pre><code>public function newAction() { $promotor = new Promotor(); $promotor-&gt;setFechaAlta(); $form = $this-&gt;createForm(new PromotorType(), $promotor); return $this-&gt;render('PromotorBundle:Promotor:new.html.twig', array( 'entity' =&gt; $promotor, 'form' =&gt; $form-&gt;createView(), )); } </code></pre> <p>Thank you so much</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload