2017 © Pedro Peláez
 

symfony-bundle xeditable-bundle

bootstrap x-editable symfony2 forms integration

image

ibrows/xeditable-bundle

bootstrap x-editable symfony2 forms integration

  • Tuesday, October 4, 2016
  • by ibrows
  • Repository
  • 15 Watchers
  • 16 Stars
  • 24,745 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 11 Forks
  • 1 Open issues
  • 14 Versions
  • 2 % Grown

The README.md

IbrowsXeditableBundle

x-editable ( http://vitalets.github.io/x-editable/ ) symfony2 forms integration, (*1)

Install & setup the bundle

  1. Add IbrowsXeditableBundle in your composer.json:, (*2)

    {
        "require": {
            "ibrows/xeditable-bundle": "~1.0",
        }
    }
    
  2. Now tell composer to download the bundle by running the command:, (*3)

    bash $ php composer.phar update ibrows/xeditable-bundle, (*4)

    Composer will install the bundle to your project's ibrows/xeditable-bundle directory. ( PSR-4 ), (*5)

  3. Add the bundles to your AppKernel class, (*6)

    php // app/AppKernerl.php public function registerBundles() { $bundles = array( // ... new Ibrows\XeditableBundle\IbrowsXeditableBundle(), // ... ); // ... }, (*7)

  4. Include JS-Lib and CSS Files, (*8)

            {% javascripts
                '@IbrowsXeditableBundle/Resources/public/javascript/bootstrap.editable-1.5.1.js'
                '@IbrowsXeditableBundle/Resources/public/javascript/xeditable.js'
            %}
                <script type="text/javascript" src="{{ asset_url }}"></script>
            {% endjavascripts %}
    
            {% stylesheets
                'bundles/ibrowsxeditable/css/bootstrap-editable.css'
            %}
                <link rel="stylesheet" type="text/css" media="screen" href="{{ asset_url }}" />
            {% endstylesheets %}
    

Basic Usage

Get the factory and wrap your form with a xeditableFormMapper, (*9)

``` php $factory = $this->get('ibrows_xeditable.mapper.factory'); $xeditableFormMapper = $factory->createFormFromRequest( 'user_xedit', //target route where data would be sent after submit array('user' => $user->getId()), // parameters for the target route $request, // request to get information about the current view, to find forward paramters new UserEditType(), // a form type with a name and a firstName field $user, // form data for the form type array('validation_groups' => arrya('edit_user')) // form options for the form type );, (*10)




Then user the xedit_inline_render function in twig to render the xeditableFormMapper XeditableMapperInterface $mapper, $formPath = null, array $attributes = array(), array $options = array()

{{ xedit_inline_render(xeditableFormMapper, 'name', {'data-emptytext': 'userName'|trans}) }} {{ xedit_inline_render(xeditableFormMapper, 'firstName', {'data-emptytext': 'firstName'|trans}) }}, (*11)


Save the xedit all request from one form in a action ``` php /** * @Route("/xedit/{user}", name="user_xedit") * @param User $user * @param Request $request * @return Response|\Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response|void */ public function xeditAction(User $user, Request $request) { $factory = $this->get('ibrows_xeditable.mapper.factory'); $xeditableFormMapper = $factory->createFormFromRequest( 'user_xedit', //target route where data would be sent after submit array('user' => $user->getId()), // parameters for the target route $request, // request to get information about the current view, to find forward paramters new UserEditType(), // a form type with some fields $user, // form data for the form type array('validation_groups' => array('edit_user')) // form options for the form type ); if ($request->isMethod('POST')) { if (($response = $xeditableFormMapper->handleRequest($request)) instanceof Response) { return $response; } $em = $this->getManagerForClass($user); $em->persist($user); $em->flush(); // after success redirect to view, so frontend can be refreshed return $this->redirectToForwardRoute($request, 'GET'); } // get back view of the handled form, to display error messages return new Response($xeditableFormMapper->renderXeditable($request->get('path'))); }

The Versions

04/10 2016

dev-master

9999999-dev http://www.ibrows.ch

bootstrap x-editable symfony2 forms integration

  Sources   Download

MIT

The Requires

 

form bootstrap symfony2 x-editable inline-edit xeditablebundle

04/10 2016

1.2.0

1.2.0.0 http://www.ibrows.ch

bootstrap x-editable symfony2 forms integration

  Sources   Download

MIT

The Requires

 

form bootstrap symfony2 x-editable inline-edit xeditablebundle

10/06 2015

1.1.6

1.1.6.0 http://www.ibrows.ch

bootstrap x-editable symfony2 forms integration

  Sources   Download

MIT

The Requires

 

form bootstrap symfony2 x-editable inline-edit xeditablebundle

10/06 2015

1.1.5

1.1.5.0 http://www.ibrows.ch

bootstrap x-editable symfony2 forms integration

  Sources   Download

MIT

The Requires

 

form bootstrap symfony2 x-editable inline-edit xeditablebundle

19/05 2015

1.1.4

1.1.4.0 http://www.ibrows.ch

bootstrap x-editable symfony2 forms integration

  Sources   Download

MIT

The Requires

 

form bootstrap symfony2 x-editable inline-edit xeditablebundle

26/02 2015

1.1.3

1.1.3.0 http://www.ibrows.ch

bootstrap x-editable symfony2 forms integration

  Sources   Download

MIT

The Requires

 

form bootstrap symfony2 x-editable inline-edit xeditablebundle

24/02 2015

1.1.2

1.1.2.0 http://www.ibrows.ch

bootstrap x-editable symfony2 forms integration

  Sources   Download

MIT

The Requires

 

form bootstrap symfony2 x-editable inline-edit xeditablebundle

23/02 2015

1.1.1

1.1.1.0 http://www.ibrows.ch

bootstrap x-editable symfony2 forms integration

  Sources   Download

MIT

The Requires

 

form bootstrap symfony2 x-editable inline-edit xeditablebundle

16/02 2015

1.1.0

1.1.0.0 http://www.ibrows.ch

bootstrap x-editable symfony2 forms integration

  Sources   Download

MIT

The Requires

 

form bootstrap symfony2 x-editable inline-edit xeditablebundle

13/02 2015

1.0.0

1.0.0.0 http://www.ibrows.ch

bootstrap x-editable symfony2 forms integration

  Sources   Download

MIT

The Requires

 

form bootstrap symfony2 x-editable inline-edit xeditablebundle

25/08 2014

0.10

0.10.0.0 http://www.ibrows.ch

bootstrap x-editable symfony2 forms integration

  Sources   Download

MIT

The Requires

 

form bootstrap symfony2 x-editable inline-edit xeditablebundle

21/08 2014

0.9

0.9.0.0 http://www.ibrows.ch

bootstrap x-editable symfony2 forms integration

  Sources   Download

MIT

The Requires

 

form bootstrap symfony2 x-editable inline-edit xeditablebundle

23/04 2014

0.8

0.8.0.0 http://www.ibrows.ch

bootstrap x-editable symfony2 forms integration

  Sources   Download

MIT

The Requires

 

form bootstrap symfony2 x-editable inline-edit xeditablebundle

23/04 2014

0.7

0.7.0.0 http://www.ibrows.ch

bootstrap x-editable symfony2 forms integration

  Sources   Download

MIT

The Requires

 

form bootstrap symfony2 x-editable inline-edit xeditablebundle