Edits an existing entity.

@param \Symfony\Component\HttpFoundation\Request $request
@param type $id
@return type
963392
public function crudUpdate(Request $request, $id)
    {
        try{
            $entity = $this->throwEntityNotFoundException($this->getRepository()->find($id));

            $form = $this->createForm($this->getEntityType(), $entity);
            $form->submit($request);
            
            $page = static::EDIT_VIEW;
            
            if ($form->isValid()) {
                $page = static::SHOW_VIEW;
                $this->saveEntity($entity);
                $form = $this->createDeleteForm($id)->createView();
                return $this->render($page, $this->commonsResponseVars(compact('entity','form')));
            }
            
            $form = $form->createView();
            $delete_form = $this->createDeleteForm($id)->createView();
            return $this->success($page, $this->commonsResponseVars(compact('entity','form','delete_form')));
            
        }catch(\Exception $e){
            return $this->failure($e);
        }
    }
564880
public function editAction(Request $request, DataInterface $data, FamilyInterface $family = null)
    {
        $this->initDataFamily($data, $family);
        $form = $this->getForm($request, $data, $family->getFormOptions());

        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $this->saveEntity($data);

            $parameters = $request->query->all();
            $parameters['success'] = 1;

            return $this->redirectToEntity($data, 'edit', $parameters);
        }

        return $this->renderAction($this->getViewParameters($request, $form, $data));
    }
1179499
public function updateAction(Request $request, $id)
    {
        $response = ['error' => false];

        try {
            $this->get('ongr_translations.translation_manager')->edit($id, $request);
        } catch (\LogicException $e) {
            $response = ['error' => true];
        }

        return new JsonResponse($response);
    }
738224
public function editBlockAction(Request $request, $id)
    {
        /** @var BlockManager $manager */
        $manager = $this->get('opifer.content.block_manager');
        $block = $manager->find($id, true);

        /** @var AbstractBlockService $service */
        $service = $manager->getService($block);
        $updatePreview = false; // signals parent window preview from iframe to update preview

        $service->preFormSubmit($block);

        $form = $this->createForm(BlockAdapterFormType::class, $block, [
            'block_service' => $service,
        ]);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $service->postFormSubmit($form, $block);

            $manager->save($block, true);
            $updatePreview = true;
        }

        $viewResponse = $this->render($service->getEditView(), [
            'block_service' => $service,
            'block' => $block,
            'form' => $form->createView(),
            'update_preview' => $updatePreview
        ]);

        return new JsonResponse([
            'title' => $service->getName($block),
            'view' => $viewResponse->getContent(),
            'updatePreview' => $updatePreview
        ]);
    }
1089452
public function editAction(Request $request, $id)
    {
        /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */
        $userManager = $this->get('fos_user.user_manager');
        /** @var $dispatcher \Symfony\Component\EventDispatcher\EventDispatcherInterface */
        $dispatcher = $this->get('event_dispatcher');

        $user = $userManager->findUserBy(['id' => $id]);
        if (!is_object($user) || !$user instanceof UserInterface) {
            return $this->redirect($this->generateUrl('cms_admin_user'));
        }

        $form = $this->get('cms.form.profile.admin.factory')->createForm();
        $form->setData($user);

        if ($request->isMethod('POST')) {
            $form->handleRequest($request);

            if ($form->isValid()) {
                $event = new GetResponseUserEvent($user, $request);
                $dispatcher->dispatch(FOSUserEvents::PROFILE_EDIT_INITIALIZE, $event);

                $userManager->updateUser($user);

                $event = new GetResponseUserEvent($user, $request);
                $dispatcher->dispatch(FOSUserEvents::PROFILE_EDIT_COMPLETED, $event);

                $this->addFlash('success', 'Данные пользовалеля <b>'.$user->getUsername().'</b> обновлены.');

                return $this->redirect($this->generateUrl('cms_admin_user'));
            }
        }

        return $this->render('@CMS/AdminUser/edit.html.twig', [
            'form' => $form->createView(),
        ]);
    }
696407
public function update($id, Request $request)
    {
        $entity = $this->getEntityById($id);

        if (!$entity) {
            return $this->response(null, Response::HTTP_NOT_FOUND);
        }

        $params = $request->only($this->fillable);

        $result = $this->manager->update($entity, $params);

        if (!$result->ok()) {
            return $this->response(['errors' => $result->getSimpleErrors()], Response::HTTP_BAD_REQUEST);
        }

        return $this->response($this->serialize($result->getResource(), $request), Response::HTTP_OK);
    }
806639
public function roleEditAction(Request $request, $id)
    {
        /** @var \Doctrine\ORM\EntityManager $em */
        $em = $this->getDoctrine()->getManager();

        $role = $em->find(Role::class, $id);

        $form = $this->createForm(RoleFormType::class, $role);

        if ($request->isMethod('POST')) {
            $form->handleRequest($request);
            if ($form->isValid()) {
                $this->persist($role, true);

                $this->addFlash('success', 'Роль обновлена.');

                return $this->redirect($this->generateUrl('cms_admin_user_roles'));
            }
        }

        return $this->render('@CMS/AdminUser/role_edit.html.twig', [
            'form' => $form->createView(),
        ]);
    }
1017822
public function editAction(Request $request, $id)
    {
        $configuration = $this->getConfiguration($request);
        $dispatcher = $configuration->getEventDispatcher();
        $om = $this->getObjectManager();

        if (!$configuration->getFormType()) {
            throw new \RuntimeException('You must set the formType on the CRUD configuration');
        }

        $object = $this->findObject($request, $id);
        $form = $this->createForm($configuration->getFormType(), $object, $configuration->getFormOptions());

        $event = new PreSubmitEvent($configuration, $request, $object, $form);
        $dispatcher->dispatch(CrudEvents::PRE_SUBMIT, $event);

        if ($event->hasResponse()) {
            return $event->getResponse();
        }

        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            if ($form->isValid()) {
                $om->persist($object);

                $event = new PreFlushEvent($configuration, $request, $object);
                $dispatcher->dispatch(CrudEvents::PRE_FLUSH, $event);

                if ($event->hasResponse()) {
                    return $event->getResponse();
                }

                $event = new PostFlushEvent($configuration, $request, $object);

                try {
                    $om->flush();
                    $this->addFlash('success', sprintf('flash.%s.edit.success', $configuration->getName()));
                } catch (\Exception $e) {
                    $event->setException($e);
                    $this->addFlash('error', sprintf('flash.%s.edit.error', $configuration->getName()));
                }

                $dispatcher->dispatch(CrudEvents::POST_FLUSH, $event);

                if ($event->hasResponse()) {
                    return $event->getResponse();
                }

                return $this->redirectToRoute(
                    $configuration->getRoutePrefix() . 'index',
                    $configuration->getRouteParameters()
                );
            } else {
                $event = new ValidationFailedEvent($configuration, $request, $object, $form);
                $dispatcher->dispatch(CrudEvents::VALIDATION_FAILED, $event);

                if ($event->hasResponse()) {
                    return $response;
                }
            }
        }

        return $this->render($this->getTemplate($request, 'edit'), array_merge([
            'base_template' => $this->getTemplate($request, 'base'),
            'config' => $configuration,
            'form'   => $form->createView(),
            'object' => $object,
        ], $configuration->getTemplateVariables()));
    }
327101
public function updateAction(Request $request, $id)
    {
        $em = $this->getDoctrine()->getManager();

        $entity = $em->getRepository('ACSACSPanelWordpressBundle:WPSetup')->find($id);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find WPSetup entity.');
        }

        $deleteForm = $this->createDeleteForm($id);
        $editForm = $this->createForm(new WPSetupType($this->container), $entity);
        $editForm->bind($request);

        if ($editForm->isValid()) {
            $em->persist($entity);
            $em->flush();

            return $this->redirect($this->generateUrl('wpsetup_edit', array('id' => $id)));
        }

        return $this->render('ACSACSPanelWordpressBundle:WPSetup:edit.html.twig', array(
            'entity'      => $entity,
            'edit_form'   => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        ));
    }
815428
public function editAction(Request $request)
    {
        $entityManager = $this->getDoctrine()->getManager();
        /** @var GlobalConfigRepository $globalConfigRepository */
        $globalConfigRepository = $entityManager->getRepository(GlobalConfig::class);
        $globalConfig = $globalConfigRepository->findLast() ?: new GlobalConfig();
        $form = $this->createForm(GlobalConfigType::class, $globalConfig, []);
        $initialLogo = $globalConfig->getLogo();
        $form->handleRequest($request);

        $success = true;
        if ($form->isSubmitted()) {
            if (true === $success = $form->isValid()) {
                //cloning the entity will give it a new id in order to invalidate browser cache (in meta.html.twig)
                $entityManager->clear(GlobalConfig::class);
                $entityManager->persist($globalConfig);
                $entityManager->flush();
                if ($initialLogo !== $globalConfig->getLogo() && $globalConfig->getLogo() !== null) {
                    $this->container->get(FaviconGenerator::class)->generate(
                        $globalConfig,
                        $this->getParameter('kernel.project_dir').'/faviconConfig.json'
                    );
                }
                $this->congrat('victoire.config.global.edit.success');

                return new JsonResponse([
                    'url'     => $this->generateUrl('victoire_core_homepage_show'),
                    'success' => true,
                ]);
            }
        }

        return new JsonResponse([
            'html' => $this->renderView('VictoireConfigBundle:global:edit.html.twig', [
                'form' => $form->createView(),
            ]),
            'success' => $success,
        ]);
    }
1122753
public function createEditForm($id) {
        $entity = $this->read_handler->get($id);
        $edit_form = $this->form_factory->create(new Type(), $entity);

        return $edit_form;
    }
549804
public function postUpdate(ModelConfigurationInterface $model, Request $request, $id)
    {
        /** @var FormInterface $editForm */
        $editForm = $model->fireEdit($id);
        $item = $editForm->getModel();

        if (is_null($item) || ! $model->isEditable($item)) {
            abort(404);
        }

        $nextAction = $request->input('next_action');

        $backUrl = $this->getBackUrl($request);

        if ($editForm instanceof FormInterface) {
            try {
                $editForm->validateForm($request, $model);

                if ($editForm->saveForm($request, $model) === false) {
                    return redirect()->back()->with([
                        '_redirectBack'       => $backUrl,
                        'sleeping_owl_tab_id' => $request->get('sleeping_owl_tab_id') ?: null,
                    ]);
                }
            } catch (ValidationException $exception) {
                return redirect()->back()
                    ->withErrors($exception->validator)
                    ->withInput()
                    ->with([
                        '_redirectBack'       => $backUrl,
                        'sleeping_owl_tab_id' => $request->get('sleeping_owl_tab_id') ?: null,
                    ]);
            }
        }

        $redirectPolicy = $model->getRedirect();

        if ($nextAction == 'save_and_continue') {
            $response = redirect()->back()->with([
                '_redirectBack'       => $backUrl,
                'sleeping_owl_tab_id' => $request->get('sleeping_owl_tab_id') ?: null,
            ]);

            if ($redirectPolicy->get('edit') == 'display') {
                $response = redirect()->to(
                    $model->getDisplayUrl()
                )->with([
                    '_redirectBack'       => $backUrl,
                    'sleeping_owl_tab_id' => $request->get('sleeping_owl_tab_id') ?: null,
                ]);
            }
        } elseif ($nextAction == 'save_and_create') {
            $response = redirect()->to($model->getCreateUrl($request->except([
                '_redirectBack',
                '_token',
                'url',
                'next_action',
            ])))->with([
                '_redirectBack'       => $backUrl,
                'sleeping_owl_tab_id' => $request->get('sleeping_owl_tab_id') ?: null,
            ]);
        } else {
            $response = redirect()->to($request->input('_redirectBack', $model->getDisplayUrl()));
        }

        return $response->with('success_message', $model->getMessageOnUpdate());
    }
550047
public function updateAction(Request $request, $id)
    {
        $title = $request->get('title');
        $rawCriteria = json_decode($request->get('criteria'), true);

        $filterManager = $this->get('phlexible_message.filter_manager');

        $filter = $filterManager->find($id);
        $filter->setTitle($title);

        $criteria = new Criteria();
        $criteria->setMode(Criteria::MODE_OR);
        foreach ($rawCriteria as $group) {
            $criteriaGroup = new Criteria();
            $criteriaGroup->setMode(Criteria::MODE_AND);
            foreach ($group as $row) {
                if (!strlen($row['value'])) {
                    continue;
                }

                $criterium = new Criterium($row['key'], $row['value']);
                $criteriaGroup->add($criterium);
            }
            if ($criteriaGroup->count()) {
                $criteria->addCriteria($criteriaGroup);
            }
        }
        $filter->setCriteria($criteria);

        $filterManager->updateFilter($filter);

        return new ResultResponse(true, 'Filter updated');
    }
548736
public function duplicateAction(Request $request, $id)
    {
        $this->init($request);
        /* @var Node $parentNode */
        $originalNode = $this->em->getRepository('KunstmaanNodeBundle:Node')
            ->find($id);

        // Check with Acl
        $this->denyAccessUnlessGranted(PermissionMap::PERMISSION_EDIT, $originalNode);

        $request = $this->get('request_stack')->getCurrentRequest();

        $originalNodeTranslations = $originalNode->getNodeTranslation($this->locale, true);
        $originalRef = $originalNodeTranslations->getPublicNodeVersion()->getRef($this->em);
        $newPage = $this->get('kunstmaan_admin.clone.helper')
            ->deepCloneAndSave($originalRef);

        //set the title
        $title = $request->get('title');
        if (is_string($title) && !empty($title)) {
            $newPage->setTitle($title);
        } else {
            $newPage->setTitle('New page');
        }

        //set the parent
        $parentNodeTranslation = $originalNode->getParent()->getNodeTranslation($this->locale, true);
        $parent = $parentNodeTranslation->getPublicNodeVersion()->getRef($this->em);
        $newPage->setParent($parent);
        $this->em->persist($newPage);
        $this->em->flush();

        /* @var Node $nodeNewPage */
        $nodeNewPage = $this->em->getRepository('KunstmaanNodeBundle:Node')->createNodeFor(
            $newPage,
            $this->locale,
            $this->user
        );

        $nodeTranslation = $nodeNewPage->getNodeTranslation($this->locale, true);
        if ($newPage->isStructureNode()) {
            $nodeTranslation->setSlug('');
            $this->em->persist($nodeTranslation);
        }
        $this->em->flush();

        $this->aclManager->updateNodeAcl($originalNode, $nodeNewPage);

        $this->addFlash(
            FlashTypes::SUCCESS,
            $this->get('translator')->trans('kuma_node.admin.duplicate.flash.success')
        );

        return $this->redirect(
            $this->generateUrl('KunstmaanNodeBundle_nodes_edit', array('id' => $nodeNewPage->getId()))
        );
    }
1356464
public function edit($id,Request $request)
    {
        if($request->ajax())
        {
            return URL::to('feature/'. $id . '/edit');
        }

         $pac = array(null => 'Package providing this feature...') + Package::orderBy('id', 'desc')->pluck('name', 'id')->all();        
        $feature = Feature::findOrfail($id);
        return view('unstarter.feature.edit',compact('feature','pac'))
            ->with('task','edit')->with('itemkind', 'features');
    }
1129107
public function editAction(Request $request, $key, $domain)
    {
        $translation = $this->get('asm_translation_loader.translation_manager')
            ->findTranslationBy(
                array(
                    'transKey' => $key,
                    'transLocale' => $request->getLocale(),
                    'messageDomain' => $domain,
                )
            );
                
        $entity = new Translation();
        $entity->setKey($translation->getTransKey());
        $entity->setDomain($domain);
        foreach ($this->getParameter('a2lix_translation_form.locales') as $k => $loc) {
            
            $translation = $this->get('asm_translation_loader.translation_manager')
                ->findTranslationBy(
                    array(
                        'transKey' => $key,
                        'transLocale' => $loc,
                        'messageDomain' => $domain,
                    )
                );
            if($translation){
                $trans = new TranslationTranslation();
                $trans->setLocale($loc);
                $trans->setValue($translation->getTranslation());
                $entity->addTranslation($trans);
            }
            
        }
        
        $deleteForm = $this->createDeleteForm($key, $domain);
        $editForm = $this->createForm('CoreBundle\Form\TranslationType', $entity);
        $editForm->handleRequest($request);

        if ($editForm->isSubmitted() && $editForm->isValid()) {
            
            //Create entry in DB
            $this->updateTranslation($entity);
            
            $this->get('session')->getFlashBag()->add('success', 'translation.edited');
            
            return $this->redirectToRoute('core_translation_index');
        }

        return $this->render('CoreBundle:Translation:edit.html.twig', array(
            'entity' => $entity,
            'edit_form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        ));
    }
325769
public function editAction(Request $request, $id)
    {
        $reviewManager = $this->get('opifer.review.review_manager');
        $review = $reviewManager->getRepository()->find($id);

        $form = $this->createForm(ReviewType::class, $review);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->flush();

            $this->addFlash('success', 'flash.review_saved');

            return $this->redirectToRoute('opifer_review_review_edit', ['id' => $id]);
        }

        return $this->render($this->getParameter('opifer_review.review_edit_view'), [
            'review' => $review,
            'form' => $form->createView(),
        ]);
    }