protected function editAction()
    {
        $this->dispatch(EasyAdminEvents::PRE_EDIT);

        $id = $this->request->query->get('id');
        $easyadmin = $this->request->attributes->get('easyadmin');
        $entity = $easyadmin['item'];

        if ($this->request->isXmlHttpRequest() && $property = $this->request->query->get('property')) {
            $newValue = 'true' === \mb_strtolower($this->request->query->get('newValue'));
            $fieldsMetadata = $this->entity['list']['fields'];

            if (!isset($fieldsMetadata[$property]) || 'toggle' !== $fieldsMetadata[$property]['dataType']) {
                throw new \RuntimeException(\sprintf('The type of the "%s" property is not "toggle".', $property));
            }

            $this->updateEntityProperty($entity, $property, $newValue);

            // cast to integer instead of string to avoid sending empty responses for 'false'
            return new Response((int) $newValue);
        }

        $fields = $this->entity['edit']['fields'];

        $editForm = $this->executeDynamicMethod('create<EntityName>EditForm', [$entity, $fields]);
        $deleteForm = $this->createDeleteForm($this->entity['name'], $id);

        $editForm->handleRequest($this->request);
        if ($editForm->isSubmitted() && $editForm->isValid()) {
            $this->dispatch(EasyAdminEvents::PRE_UPDATE, ['entity' => $entity]);
            $this->executeDynamicMethod('update<EntityName>Entity', [$entity, $editForm]);
            $this->dispatch(EasyAdminEvents::POST_UPDATE, ['entity' => $entity]);

            return $this->redirectToReferrer();
        }

        $this->dispatch(EasyAdminEvents::POST_EDIT);

        $parameters = [
            'form' => $editForm->createView(),
            'entity_fields' => $fields,
            'entity' => $entity,
            'delete_form' => $deleteForm->createView(),
        ];

        return $this->executeDynamicMethod('render<EntityName>Template', ['edit', $this->entity['templates']['edit'], $parameters]);
    }
protected function editAction()
    {
        $this->dispatch(EasyAdminEvents::PRE_EDIT);

        $id = $this->request->query->get('id');
        $easyadmin = $this->request->attributes->get('easyadmin');
        $entity = $easyadmin['item'];

        if ($this->request->isXmlHttpRequest() && $property = $this->request->query->get('property')) {
            $newValue = 'true' === \mb_strtolower($this->request->query->get('newValue'));
            $fieldsMetadata = $this->entity['list']['fields'];

            if (!isset($fieldsMetadata[$property]) || 'toggle' !== $fieldsMetadata[$property]['dataType']) {
                throw new \RuntimeException(\sprintf('The type of the "%s" property is not "toggle".', $property));
            }

            $this->updateEntityProperty($entity, $property, $newValue);

            // cast to integer instead of string to avoid sending empty responses for 'false'
            return new Response((int) $newValue);
        }

        $fields = $this->entity['edit']['fields'];

        $editForm = $this->executeDynamicMethod('create<EntityName>EditForm', [$entity, $fields]);
        $deleteForm = $this->createDeleteForm($this->entity['name'], $id);

        $editForm->handleRequest($this->request);
        if ($editForm->isSubmitted() && $editForm->isValid()) {
            $this->dispatch(EasyAdminEvents::PRE_UPDATE, ['entity' => $entity]);
            $this->executeDynamicMethod('update<EntityName>Entity', [$entity, $editForm]);
            $this->dispatch(EasyAdminEvents::POST_UPDATE, ['entity' => $entity]);

            return $this->redirectToReferrer();
        }

        $this->dispatch(EasyAdminEvents::POST_EDIT);

        $parameters = [
            'form' => $editForm->createView(),
            'entity_fields' => $fields,
            'entity' => $entity,
            'delete_form' => $deleteForm->createView(),
        ];

        return $this->executeDynamicMethod('render<EntityName>Template', ['edit', $this->entity['templates']['edit'], $parameters]);
    }
protected function editAction ( ) { $ this -> dispatch ( EasyAdminEvents :: PRE_EDIT ) ; $ id = $ this -> request -> query -> get ( 'id' ) ; $ easyadmin = $ this -> request -> attributes -> get ( 'easyadmin' ) ; $ entity = $ easyadmin [ 'item' ] ; if ( $ this -> request -> isXmlHttpRequest ( ) && $ property = $ this -> request -> query -> get ( 'property' ) ) { $ newValue = 'true' === \ mb_strtolower ( $ this -> request -> query -> get ( 'newValue' ) ) ; $ fieldsMetadata = $ this -> entity [ 'list' ] [ 'fields' ] ; if ( ! isset ( $ fieldsMetadata [ $ property ] ) || 'toggle' !== $ fieldsMetadata [ $ property ] [ 'dataType' ] ) { throw new \ RuntimeException ( \ sprintf ( 'The type of the "%s" property is not "toggle".' , $ property ) ) ; } $ this -> updateEntityProperty ( $ entity , $ property , $ newValue ) ; // cast to integer instead of string to avoid sending empty responses for 'false' return new Response ( ( int ) $ newValue ) ; } $ fields = $ this -> entity [ 'edit' ] [ 'fields' ] ; $ editForm = $ this -> executeDynamicMethod ( 'create<EntityName>EditForm' , [ $ entity , $ fields ] ) ; $ deleteForm = $ this -> createDeleteForm ( $ this -> entity [ 'name' ] , $ id ) ; $ editForm -> handleRequest ( $ this -> request ) ; if ( $ editForm -> isSubmitted ( ) && $ editForm -> isValid ( ) ) { $ this -> dispatch ( EasyAdminEvents :: PRE_UPDATE , [ 'entity' => $ entity ] ) ; $ this -> executeDynamicMethod ( 'update<EntityName>Entity' , [ $ entity , $ editForm ] ) ; $ this -> dispatch ( EasyAdminEvents :: POST_UPDATE , [ 'entity' => $ entity ] ) ; return $ this -> redirectToReferrer ( ) ; } $ this -> dispatch ( EasyAdminEvents :: POST_EDIT ) ; $ parameters = [ 'form' => $ editForm -> createView ( ) , 'entity_fields' => $ fields , 'entity' => $ entity , 'delete_form' => $ deleteForm -> createView ( ) , ] ; return $ this -> executeDynamicMethod ( 'render<EntityName>Template' , [ 'edit' , $ this -> entity [ 'templates' ] [ 'edit' ] , $ parameters ] ) ; }
The method that is executed when the user performs a 'edit' action on an entity.

@return Response|RedirectResponse

@throws \RuntimeException
The method that is executed when the user performs a edit action on an entity .