Пример #1
0
 /**
  * Remove fieldOptionMerge
  *
  * @param FieldOptionMerge $fieldOptionMerge
  */
 public function removeFieldOptionMerge(FieldOptionMerge $fieldOptionMerge)
 {
     $this->fieldOptionMerge->removeElement($fieldOptionMerge);
 }
Пример #2
0
 /**
  * Edits an existing FieldOption entity.
  *
  * @Secure(roles="ROLE_SUPER_USER,ROLE_FIELDOPTION_UPDATE")
  * @Route("/{id}", requirements={"id"="\d+"}, name="fieldoption_update")
  * @Method("PUT")
  * @Template("HrisFormBundle:FieldOption:edit.html.twig")
  */
 public function updateAction(Request $request, $id)
 {
     $em = $this->getDoctrine()->getManager();
     $entity = $em->getRepository('HrisFormBundle:FieldOption')->find($id);
     if (!$entity) {
         throw $this->createNotFoundException('Unable to find FieldOption entity.');
     }
     $deleteForm = $this->createDeleteForm($id);
     $editForm = $this->createForm(new FieldOptionType($entity->getField()->getId()), $entity);
     $editForm->submit($request);
     if ($editForm->isValid()) {
         $requestcontent = $request->request->get('hris_formbundle_fieldoptiontype');
         $fieldOptionIds = $requestcontent['fieldOptionMerge'];
         // Clear ResourceTableFieldMembers
         //Get rid of current merged fields options
         $em->createQueryBuilder('fieldOptionMerge')->delete('HrisFormBundle:FieldOptionMerge', 'fieldOptionMerge')->where('fieldOptionMerge.mergedFieldOption= :mergedFieldOption')->setParameter('mergedFieldOption', $entity)->getQuery()->getResult();
         $em->flush();
         foreach ($fieldOptionIds as $fieldOptionIdKey => $fieldOptionId) {
             $fieldOption = $this->getDoctrine()->getRepository('HrisFormBundle:FieldOption')->findOneBy(array('id' => $fieldOptionId));
             $fieldOptionMerge = new FieldOptionMerge();
             $fieldOptionMerge->setField($entity->getField());
             $fieldOptionMerge->setMergedFieldOption($entity);
             $fieldOptionMerge->setRemovedFieldOptionValue($fieldOption->getValue());
             $fieldOptionMerge->setRemovedFieldOptionUid($fieldOption->getUid());
             $em->persist($fieldOptionMerge);
             unset($fieldOption);
         }
         $em->persist($entity);
         $em->flush();
         return $this->redirect($this->generateUrl('fieldoption_show', array('id' => $id)));
     }
     return array('entity' => $entity, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView());
 }