wh/xeditable-bundle

Symfony WHXEditableBundle

Installs: 7

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Open Issues: 1

Language:JavaScript

Type:symfony-bundle

dev-master 2016-04-04 07:50 UTC

This package is not auto-updated.

Last update: 2022-10-01 08:00:41 UTC


README

App Kernel

new WH\XEditableBundle\WHXEditableBundle(),

layout :

...

{{ XeditablGetLib() | raw }}

</body>

On a balise :

<span {{ XEditableEntity({'id' : Entity.id, 'route' : 'route_name', 'field' : 'fieltochange'}) }}>{{ Entity.name }}</span> :

In controller

/**
 * @Route("/editfield", name="bk_user_edit_field")
 * @param $id
 * @param $field
 * @param $value
 */
public function editField(Request $request) {

    $em = $this->getDoctrine()->getManager();

    $personn = $em->getRepository('AppBundle:Personn')->findOneById($request->request->get('pk'));

    switch($request->request->get('name')) {

        case 'firstname' :
            $personn->setFirstName($request->request->get('value'));
            break;

        case 'lastname' :
            $personn->setLastName($request->request->get('value'));
            break;

    }


    $em->persist($personn);

    $em->flush();

    exit('ok');


}