/** * Creates a new Job entity. */ public function createAction(Request $request) { $entity = new Job(); $entity->setCompany('Company One'); // should pre-populate field $form = $this->createForm(new JobType(), $entity); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getEntityManager(); $em->persist($entity); $em->flush(); return $this->redirect($this->generateUrl('Sm_job_preview', array('company' => $entity->getCompanySlug(), 'location' => $entity->getLocationSlug(), 'token' => $entity->getToken(), 'position' => $entity->getPositionSlug()))); } return $this->render('JobsBundle:Job:new.html.twig', array('entity' => $entity, 'form' => $form->createView())); }
/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('type', 'choice', array('choices' => Job::getTypes(), 'expanded' => true, 'data' => 'full-time'))->add('company', 'text', array())->add('file', 'file', array('label' => 'Company logo', 'required' => false))->add('url', null, array())->add('position', null, array())->add('location', null, array())->add('description', null, array())->add('how_to_apply', null, array('label' => 'How to apply?'))->add('is_public', null, array('label' => 'Public?'))->add('email', null, array())->add('category', null, array()); }