示例#1
0
 public function createFilledField(BuilderInterface $builder, Form $form = null, $name = null)
 {
     $field = new Field();
     if ($form) {
         $field->setPosition($form->getFields()->count() + 1);
         $field->setForm($form);
         $field->setName(sprintf("%s_%d", $this->get('translator')->trans('geny.builder.field.name', [], 'geny'), $field->getPosition()));
     }
     if ($name) {
         $field->setName($name);
     }
     $field->setType($builder->getName());
     $field->setData($builder->getDefaultData($field));
     $field->setOptions(null);
     $field->setConstraints(null);
     $field->setLabel($this->get('translator')->trans('geny.builder.field.label', [], 'geny'));
     $field->setHelp($this->get('translator')->trans('geny.builder.field.help', [], 'geny'));
     $field->setRequired(true);
     return $field;
 }
示例#2
0
 public function addBuilder(BuilderInterface $builder)
 {
     $this->builders[$builder->getName()] = $builder;
 }
示例#3
0
 public function getConstraintsType(BuilderInterface $builder, Field $entity, $data)
 {
     $type = $this->get('form.factory')->createNamedBuilder(sprintf("constraints-%d", $entity->getId()), Type\FormType::class, $data, ['translation_domain' => 'geny']);
     foreach ($builder->supportsConstraints($entity) as $constraintClass) {
         $constraint = $this->getCachedObject($constraintClass);
         $constraint->build($type, $entity, $data);
     }
     return $type->getForm();
 }