Can someone tell me, I have a list of criteria, they have the docRequired flag in the entity, I want to display them, and if the flag is true, show an input with the filetype.

In general, the whole essence of what is RegistrationRequest, and part of this CriteriaRequest which has PriorityRequest, below I will try to insert the code that I am trying to do.

class PriorityCriteria { /** * @var int * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var EducationLevel[]|ArrayCollection * @ORM\ManyToMany(targetEntity="AppBundle\Entity\EducationLevel") */ private $educationLevels; /** * @var string * @ORM\Column(name="text", type="text") */ private $text; /** * @var bool * * @ORM\Column(name="doc_required", type="boolean") */ private $docRequired = false; class CriteriaRequest { /** * @var int * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * Many User have Many Phonenumbers. * @ORM\ManyToMany(targetEntity="PriorityCriteria") * @ORM\JoinTable(name="criteria_criteriarequest", * joinColumns={@ORM\JoinColumn(name="criteria_id", referencedColumnName="id")}, * inverseJoinColumns={@ORM\JoinColumn(name="criteriarequest_id", referencedColumnName="id", unique=true)} * ) */ private $priorityCriteria; /** * * @ORM\ManyToOne(targetEntity="RegistrationRequest", inversedBy="criteriaRequest") * @ORM\JoinColumn(name="registration_request_id", referencedColumnName="id") */ private $registrationRequest; /** * @var string * @ORM\Column(name="doc", type="string", length=255, nullable=true) */ private $doc; 

I tried to get the list of criteria right away and insert them into the formType and, through the choice function, output then in the template, how it is possible to output by variables. But then I don’t know how to save it later ... And another option in FormType is to pass an empty object CriteriaRequest and through the queryBuilder inside I can get the criteria, but then I can just generate the criteria and the input Doc type is not

  public function criteriaRequestListAction(Request $request, $educationLevel) { $em = $this->getDoctrine()->getManager(); // $criteria = $em->getRepository('RegistrationBundle:PriorityCriteria')->getCriteriaList($educationLevel); $criteria = new CriteriaRequest(); $form = $this->createForm(CriteriaRequestType::class, $criteria); $form->handleRequest($request); // dump($form);die; if ($form->isSubmitted() && $form->isValid()) { dump($criteria);die; $em->persist($criteria); $em->flush(); return $this->redirectToRoute('criteria_index'); } 

form itself ...

  class CriteriaRequestType extends AbstractType { /** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('priorityCriteria', EntityType::class, [ 'class' => 'RegistrationBundle:PriorityCriteria', 'choice_label' => 'text', 'mapped' => false, // 'choice_label' => function ($priorityCriterias) { // return $priorityCriterias->getText(); // }, 'query_builder' => function (EntityRepository $er) { return $er->getCriteriaList(); }, 'multiple' => true, 'expanded' => true, ]) ->add('save', SubmitType::class, ['attr' => ['class' => 'btn btn-success']]); } 

In general, can I really try to implement a curved logic ?? I'm tired of solving this problem, it’s not served, can someone tell me what)

    0