Displays a form to edit an existing sakonninTemplate entity.

@Route("/{id}/edit", name="sakonnintemplate_edit", methods={"GET", "POST"})
517627
public function editAction(Request $request, SakonninTemplate $sakonninTemplate)
    {
        $deleteForm = $this->createDeleteForm($sakonninTemplate);
        $editForm = $this->createForm('BisonLab\SakonninBundle\Form\SakonninTemplateType', $sakonninTemplate);
        $editForm->handleRequest($request);

        if ($editForm->isSubmitted() && $editForm->isValid()) {
            $em = $this->getDoctrineManager()->flush();

            return $this->redirectToRoute('sakonnintemplate_show', array('id' => $sakonninTemplate->getId()));
        }

        return $this->render('BisonLabSakonninBundle:SakonninTemplate:edit.html.twig',
            array(
                'sakonninTemplate' => $sakonninTemplate,
                'edit_form' => $editForm->createView(),
                'delete_form' => $deleteForm->createView(),
        ));
    }
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);
        }
    }
57502
protected function editTemplateAction()
    {
        $id = $this->params('id');
        $formIdentifier=$this->params()->fromQuery('form');
        //$job = $this->jobRepository->find($id);
        $job = $this->initializeJob()->get($this->params(), true, true); /* @var \Jobs\Entity\Job $job */
        $this->acl($job, 'edit');

        /** @var \Zend\Http\Request $request */
        $request              = $this->getRequest();
        $isAjax               = $request->isXmlHttpRequest();
        $viewHelperManager    = $this->viewHelper;
        $mvcEvent             = $this->getEvent();
        $applicationViewModel = $mvcEvent->getViewModel();
        $forms                = $this->formManager;

        /** @var \Jobs\Form\JobDescriptionTemplate $formTemplate */
        $formTemplate         = $forms->get(
            'Jobs/Description/Template',
            array(
            'mode' => $job->getId() ? 'edit' : 'new'
            )
        );

        $formTemplate->setParam('id', $job->getId());
        $formTemplate->setParam('applyId', $job->getApplyId());
        $formTemplate->setParam('snapshot', $job instanceof JobSnapshot ? $job->getSnapshotId() : '');

        $formTemplate->setEntity($job);

        if (isset($formIdentifier) && $request->isPost()) {
            // at this point the form get instantiated and immediately accumulated

            $instanceForm = $formTemplate->get($formIdentifier);
            if (!isset($instanceForm)) {
                throw new \RuntimeException('No form found for "' . $formIdentifier . '"');
            }

            // the id is part of the postData, but it never should be altered
            $postData = $request->getPost();

            unset($postData['id']);
            unset($postData['applyId']);
            unset($postData['snapshot']);

            $instanceForm->setData($postData);
            if ($instanceForm->isValid()) {
                $this->jobRepository->store($job);
            }
        }

        $model = $this->viewModelTemplateFilter->getModel($formTemplate);

        if (!$isAjax) {
            $basePath   = $viewHelperManager->get('basepath');
            $headScript = $viewHelperManager->get('headscript');
            $asset = $viewHelperManager->get('asset');
            $headScript->appendFile($basePath('dist/js/core.js'));
            $headScript->appendFile($basePath->__invoke('modules/Core/js/core.forms.js'));
            $headScript->appendScript('
                $(document).ready(function() {
                    var submitTextarea = function($area, $form) {
                        var bg = $area.css("background-color");
                        $area.css("background-color", "lightgrey");
                        $form.one("yk:forms:success yk:forms:fail", function() { $area.css("background-color", bg); }).submit();
                    };

                    $("textarea").blur(function(e) { var $area = $(e.target); submitTextarea($area, $area.parents("form")); })
                                 .keydown(function(e) { if ((10 == e.keyCode || 13 == e.keyCode) && e.ctrlKey) {
                                                var $area = $(e.target); submitTextarea($area, $area.parents("form"));
                                          }});
                });
            ');

            $headStyle = $viewHelperManager->get('headstyle');
            $headStyle->prependStyle(
                'form > input {
            color: inherit !important; margin:inherit !important;
            padding:inherit !important; border:0 !important; cursor:pointer !important; letter-spacing:inherit !important;
            line-height: inherit !important;
             font-size: inherit !important;
}
'
            );
        } else {
            return new JsonModel(array('valid' => true));
        }
        $applicationViewModel->setTemplate('iframe/iFrameInjection');
        return $model;
    }
388961
def edit(options = { only: [], except: [:id, :created_at, :updated_at], required: [] })
      @required_keys = options[:required]
      @attrs = CEO::Iterator.filter(@thing.attributes.keys, options)
      @model = @thing.model_name.name.constantize
      @route_name ||= @controller_name ||= controller_name
      @index_route = send(:"admin_#{@route_name}_path")

      render 'admin/edit'
    end
211228
public function editAction($id, Request $request)
    {
        $cm = new CronManager();
        $crons = $cm->get();
        $this->addFlashFromCronManager($cm);
        $form = $this->createCronForm($crons[$id]);

        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $cm->write();

            $this->addFlashFromCronManager($cm);

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

        return $this->render('@BCCCronManager:Default:edit.html.twig', array(
            'form'  => $form->createView(),
        ));
    }
869270
public function editAction(Request $request, $access, Message $message)
    {
        $this->denyAccessUnlessGranted('edit', $message);
        $editForm = $this
            ->createForm('BisonLab\SakonninBundle\Form\MessageType', $message);
        $editForm->handleRequest($request);

        if ($editForm->isSubmitted()) {
            if ($editForm->isValid()) {
                $this->getDoctrineManager()->flush();

                if ($this->isRest($access)) {
                    return new JsonResponse(array("status" => "OK", 200));
                }
                return $this->redirectToRoute('message_show',
                    array('access' => $access, 'id' => $message->getId()));
           } else {
                $errors = $this->handleFormErrors($editForm);
                return new JsonResponse(array("status" => "ERROR",
                    'errors' => $errors), 422);
            }
        }

        if ($this->isRest($access)) {
            return $this
                    ->render('BisonLabSakonninBundle:Message:_edit.html.twig',
                array(
                    'message' => $message,
                    'edit_form' => $editForm->createView(),
            ));
        }
        $deleteForm = $this->createDeleteForm($message);
        return $this->render('BisonLabSakonninBundle:Message:edit.html.twig',
            array(
                'message' => $message,
                'edit_form' => $editForm->createView(),
                'delete_form' => $deleteForm->createView(),
        ));
    }
1251028
public function editAction($id, Request $request)
    {
        $contentType = $this->contentTypeManager->getContentTypeById($id);

        if ($contentType === null) {
            throw EntityNotFoundException::fromClassNameAndIdentifier(
                $this->configurationManager->getEntityClass('content_type'),
                [$id]
            );
        }

        $fieldTypes = [];
        foreach ($contentType->getFields() as $field) {
            $fieldTypes[$field->getId()] = $field->getType();
        }

        $form = $this->createForm(ContentTypeFormType::class, $contentType, [
            'action' => $this->generateUrl('sherlockode_acb_content_type_edit', ['id' => $contentType->getId()]),
            'attr' => [
                'data-change-type-url' => $this->generateUrl('sherlockode_acb_content_type_change_field_type'),
                'class' => 'edit-content-type'
            ],
            'contentType' => $contentType,
        ]);

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $this->contentTypeManager->processFieldsChangeType($contentType, $fieldTypes);
            $this->om->flush();

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

        return $this->render('@SherlockodeAdvancedContent/ContentType/edit_content_type.html.twig', [
            'form' => $form->createView(),
            'data' => $contentType,
        ]);
    }
799105
def edit(
    request,
    slug,
    rev_id=None,
    template_name='wakawaka/edit.html',
    extra_context=None,
    wiki_page_form=WikiPageForm,
    wiki_delete_form=DeleteWikiPageForm,
):
    
    # Get the page for slug and get a specific revision, if given
    try:
        queryset = WikiPage.objects.all()
        page = queryset.get(slug=slug)
        rev = page.current
        initial = {'content': page.current.content}

        # Do not allow editing wiki pages if the user has no permission
        if not request.user.has_perms(
            ('wakawaka.change_wikipage', 'wakawaka.change_revision')
        ):
            return HttpResponseForbidden(
                ugettext('You don\'t have permission to edit pages.')
            )

        if rev_id:
            # There is a specific revision, fetch this
            rev_specific = Revision.objects.get(pk=rev_id)
            if rev.pk != rev_specific.pk:
                rev = rev_specific
                rev.is_not_current = True
                initial = {
                    'content': rev.content,
                    'message': _('Reverted to "%s"' % rev.message),
                }

    # This page does not exist, create a dummy page
    # Note that it's not saved here
    except WikiPage.DoesNotExist:

        # Do not allow adding wiki pages if the user has no permission
        if not request.user.has_perms(
            ('wakawaka.add_wikipage', 'wakawaka.add_revision')
        ):
            return HttpResponseForbidden(
                ugettext('You don\'t have permission to add wiki pages.')
            )

        page = WikiPage(slug=slug)
        page.is_initial = True
        rev = None
        initial = {
            'content': _('Describe your new page %s here...' % slug),
            'message': _('Initial revision'),
        }

    # Don't display the delete form if the user has nor permission
    delete_form = None
    # The user has permission, then do
    if request.user.has_perm(
        'wakawaka.delete_wikipage'
    ) or request.user.has_perm('wakawaka.delete_revision'):
        delete_form = wiki_delete_form(request)
        if request.method == 'POST' and request.POST.get('delete'):
            delete_form = wiki_delete_form(request, request.POST)
            if delete_form.is_valid():
                return delete_form.delete_wiki(request, page, rev)

    # Page add/edit form
    form = wiki_page_form(initial=initial)
    if request.method == 'POST':
        form = wiki_page_form(data=request.POST)
        if form.is_valid():
            # Check if the content is changed, except there is a rev_id and the
            # user possibly only reverted the HEAD to it
            if (
                not rev_id
                and initial['content'] == form.cleaned_data['content']
            ):
                form.errors['content'] = (_('You have made no changes!'),)

            # Save the form and redirect to the page view
            else:
                try:
                    # Check that the page already exist
                    queryset = WikiPage.objects.all()
                    page = queryset.get(slug=slug)
                except WikiPage.DoesNotExist:
                    # Must be a new one, create that page
                    page = WikiPage(slug=slug)
                    page.save()

                form.save(request, page)

                kwargs = {'slug': page.slug}

                redirect_to = reverse('wakawaka_page', kwargs=kwargs)
                messages.success(
                    request,
                    ugettext('Your changes to %s were saved' % page.slug),
                )
                return HttpResponseRedirect(redirect_to)

    template_context = {
        'form': form,
        'delete_form': delete_form,
        'page': page,
        'rev': rev,
    }
    template_context.update(extra_context or {})
    return render(request, template_name, template_context)
653286
public function edit($id, $template = false)
    {
        // if the template in the GET parameter is missing, figure it out from the db
        if ($template == false) {
            $model = $this->crud->model;
            $this->data['entry'] = $model::findOrFail($id);
            $template = $this->data['entry']->template;
        }

        $this->addDefaultGeoFields($template);
        $this->useTemplate($template);

        return parent::edit($id);
    }
1078637
public function editAction($id, Request $request)
    {
        $form = $this->container->get('form.factory')->createNamed(
            'skeleton',
            EditionType::class,
            $template = $this->container->get('synapse.template.loader')
                ->retrieveAll(array('id' => $id, 'scope' => TemplateInterface::GLOBAL_SCOPE))
                ->first(),
            array(
                'theme' => $request->attributes->get(
                    'synapse_theme',
                    $this->container->get('synapse')
                        ->enableDefaultTheme()
                        ->getCurrentTheme()
                ),
                'content_type' => $template->getContentType(),
                'action' => $formUrl = $this->container->get('router')->generate(
                    'synapse_admin_skeleton_edition',
                    array('id' => $template->getId())
                ),
                'method' => 'POST',
                'csrf_protection' => false,
            )
        );
        if ($request->request->has('skeleton')) {
            $form->handleRequest($request);
            if ($form->isValid()) {
                return $this->redirect(
                    $this->container->get('router')->generate(
                        'synapse_admin_skeleton_edition',
                        array('id' => $template->getId())
                    )
                );
            }
        }

        return $this->render('SynapseAdminBundle:Skeleton:edit.html.twig', array(
            'skeleton' => $template,
            'form' => $form->createView(),
        ));
    }
815957
public function editTypeAction(Request $request, $id)
    {
        /** @var ContentManager $manager */
        $manager = $this->get('opifer.content.content_manager');

        /** @var Content $content */
        $content = $manager->getRepository()->find($id);

        $form = $this->createFormBuilder($content)
            ->add('contentType', EntityType::class, [
                'class' => $this->get('opifer.content.content_type_manager')->getClass(),
                'choice_label' => 'name',
            ])
            ->getForm();

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            /** @var EavManager $eavManager */
            $eavManager = $this->get('opifer.eav.eav_manager');
            $valueSet = $eavManager->createValueSet();

            $this->getDoctrine()->getManager()->persist($valueSet);

            $valueSet->setSchema($content->getContentType()->getSchema());
            $content->setValueSet($valueSet);

            $manager->save($content);

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

        return $this->render($this->getParameter('opifer_content.content_edit_type'), [
            'content' => $content,
            'form' => $form->createView(),
        ]);
    }
700320
public function editAction()
    {
        $form = $this->getEditForm();
        $entity = $form->getObject();
        if ($this->getRequest()->isPost()) {
            $data = $this->getRequest()->getPost()->toArray();
            $entityManager = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');
            $hydrator = new DoctrineHydrator($entityManager);
            $hydrator->hydrate($data, $entity);

            if ($form->isValid()) {
                $objectManager = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');
                $objectManager->persist($entity);
                $objectManager->flush();
                $controller = explode('/', $this->getRequest()->getUri()->getPath())[2];
                if (!$this->getRequest()->isXmlHttpRequest()) {
                    return $this->redirect()->toRoute(null, ['controller' => $controller]);
                }
                return;
            } else {
                $this->getResponse()->setStatusCode(400);
            }
        }
        $viewModel = $this->getViewModel();
        $viewModel->setTerminal($this->getRequest()->isXmlHttpRequest());

        return $viewModel->setVariables(['form' => $form]);
    }
375774
public function editAction(Request $request, PaymentServiceProvider $paymentServiceProvider)
    {
        $deleteForm = $this->createDeleteForm($paymentServiceProvider);
        $editForm = $this->createForm('EcommerceBundle\Form\PaymentServiceProviderType', $paymentServiceProvider);
        $editForm->handleRequest($request);

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

            return $this->redirectToRoute('ecommerce_paymentserviceprovider_edit', array('id' => $paymentServiceProvider->getId()));
        }

        return array(
            'entity' => $paymentServiceProvider,
            'edit_form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }
817382
public function edit(Request $request, $id)
    {
        $slug = $this->getSlug($request);

        $dataType = Admin::model('DataType')->where('slug', '=', $slug)->first();

        // Compatibility with Model binding.
        $id = $id instanceof Model ? $id->{$id->getKeyName()} : $id;

        $relationships = $this->getRelationships($dataType);

        $dataTypeContent = (strlen($dataType->model_name) != 0)
            ? app($dataType->model_name)->with($relationships)->findOrFail($id)
            : DB::table($dataType->name)->where('id', $id)->first(); // If Model doest exist, get data from table name

        foreach ($dataType->editRows as $key => $row) {
            $details = json_decode($row->details);
            $dataType->editRows[$key]['col_width'] = isset($details->width) ? $details->width : 100;
        }

        // If a column has a relationship associated with it, we do not want to show that field
        $this->removeRelationshipField($dataType, 'edit');

        // Check permission
        $this->authorize('edit', $dataTypeContent);

        // Check if CRUD is Translatable
        $isModelTranslatable = is_crud_translatable($dataTypeContent);

        $view = 'admin::crud.edit-add';

        if (view()->exists("admin::$slug.edit-add")) {
            $view = "admin::$slug.edit-add";
        }

        return Admin::view($view, compact('dataType', 'dataTypeContent', 'isModelTranslatable'));
    }
1092492
public function editAction(Request $request, Localidad $localidad)
    {
        $deleteForm = $this->createDeleteForm($localidad);
        $editForm = $this->createForm('Matudelatower\UbicacionBundle\Form\Type\LocalidadType', $localidad);
        $editForm->handleRequest($request);

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

            return $this->redirectToRoute('localidad_edit', array('id' => $localidad->getId()));
        }

        return $this->render('UbicacionBundle:localidad:edit.html.twig', array(
            'localidad' => $localidad,
            'edit_form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        ));
    }
217917
public function editAction(Request $request, $id)
    {
        /** @var ConfiguratorFactory $configuratorFactory */
        $configuratorFactory = $this->getConfiguratorFactory($this->getClassName());
        /** @var CrudConfigurator $crudConfigurator */
        $crudConfigurator = $configuratorFactory->getConfigurator(CrudConfigurator::class);

        $this->isGrantedOr404Error($crudConfigurator, Constants::ACTION_UPDATE);

        $model = $this->findOr404Error($id);
        $form = $crudConfigurator->getForm($model);

        return $this->createOrUpdate($request, $model, $form, Constants::ACTION_UPDATE, $crudConfigurator->getTemplate()->getEdit());
    }
869755
public function editAction()
    {
        $default    = false;
        $params     = $this->params();
        $request    = $this->getRequest();
        $locator    = $this->getServiceLocator();
        $model      = $locator->get( 'Grid\Core\Model\SubDomain\Model' );
        /* @var $form \Zend\Form\Form */
        $form       = $locator->get( 'Form' )
                              ->create( 'Grid\Core\SubDomain' );

        if ( ( $id = $params->fromRoute( 'id' ) ) )
        {
            $subDomain = $model->find( $id );

            if ( empty( $subDomain ) )
            {
                $this->getResponse()
                     ->setStatusCode( 404 );

                return;
            }

            if ( empty( $subDomain->subdomain ) )
            {
                $default = true;

                $form->get( 'subdomain' )
                     ->setRequired( false );
            }
        }
        else
        {
            if ( ! $this->getServiceLocator()
                        ->get( 'Grid\User\Model\Permissions\Model' )
                        ->isAllowed( 'subDomain', 'create' ) )
            {
                $this->getResponse()
                     ->setStatusCode( 403 );

                return;
            }

            $subDomain = $model->create( array() );
        }

        /* @var $form \Zend\Form\Form */
        $form->setHydrator( $model->getMapper() )
             ->bind( $subDomain );

        if ( $request->isPost() )
        {
            $form->setData( $request->getPost() );

            if ( $form->isValid() && $subDomain->save() )
            {
                if ( $default && ! empty( $subDomain->subdomain ) )
                {
                    $newDefault = $model->create( array(
                        'subdomain'         => '',
                        'locale'            => $subDomain->locale,
                        'defaultLayoutId'   => $subDomain->defaultLayoutId,
                        'defaultContentId'  => $subDomain->defaultContentId,
                    ) );

                    $newDefault->save();
                }

                $this->messenger()
                     ->add( 'subDomain.form.success',
                            'subDomain', Message::LEVEL_INFO );

                return $this->redirect()
                            ->toRoute( 'Grid\Core\SubDomain\List', array(
                                'locale' => (string) $this->locale(),
                            ) );
            }
            else
            {
                $this->messenger()
                     ->add( 'subDomain.form.failed',
                            'subDomain', Message::LEVEL_ERROR );
            }
        }

        $form->setCancel(
            $this->url()
                 ->fromRoute( 'Grid\Core\SubDomain\List', array(
                        'locale' => (string) $this->locale(),
                    ) )
        );

        return array(
            'form'      => $form,
            'subDomain' => $subDomain,
        );
    }