The following (simple) question from me:
$user = new User();
$user->setEventid(2);
$user->setT(new \DateTime('now'));
$em = $this->getDoctrine()->getManager();
$em->persist($user);
$em->flush();
$form = $this->createFormBuilder($user)
->add('email', 'email')
->add('terms', 'checkbox', array(
'label' => 'Read terms?',
'required' => true))
->getForm();
This is my code. Email is property of the user, terms not.
I want them users to save their email and check the terms-checkbox but i just need to save the email, not if they check the box – if they don’t they cant submit the form.
You know what i mean? I’m shure its pretty simple to achieve this 😉
Second Question: How can i give the rendered from-tag an id-attribute for further handeling in jquery?
To add a field that doesn’t exist in the entity to a form, use this:
Symfony generates an ID for each form element; just open the rendered page source and see the ID of the element you need.