Пример #1
0
 public function buildForm(FormBuilder $builder, array $options)
 {
     $builder->add('constraintType', 'choice', array('label' => 'field.constrainttype', 'choices' => FieldConstraint::getConstrainttypeTypes(), 'multiple' => false, 'empty_data' => null, 'required' => true))->add('message', 'textarea', array('label' => 'field.message', 'required' => false))->add('parameter1', 'text', array('label' => 'field.parameter1', 'required' => false))->add('parameter2', 'text', array('label' => 'field.parameter2', 'required' => false));
 }
Пример #2
0
 public function createConstraintAction()
 {
     $request = $this->get('request');
     $fieldId = $request->request->get('fieldId');
     $type = $request->request->get('type');
     $message = $request->request->get('message');
     $param1 = $request->request->get('param1');
     $param2 = $request->request->get('param2');
     $em = $this->getDoctrine()->getEntityManager();
     $field = $em->getRepository('LowbiConfiguratorBundle:Field')->find($fieldId);
     $entity = new FieldConstraint();
     $entity->setConstraintType($type);
     $entity->setMessage($message);
     $entity->setParameter1($param1);
     $entity->setParameter1($param1);
     $entity->setField($field);
     $em->persist($entity);
     $em->flush();
     $entity = new FieldConstraint();
     $form = $this->createForm(new FieldConstraintType(), $entity);
     $field = $em->getRepository('LowbiConfiguratorBundle:Field')->find($fieldId);
     $fieldConstraints = $field->getFieldConstraints();
     return $this->render('LowbiConfiguratorBundle:FieldConstraint:newConstraint.html.twig', array('entity' => $entity, 'form' => $form->createView(), 'fieldConstraints' => $fieldConstraints));
 }