1. Go to this page and download the library: Download ibrows/xeditable-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
php
// app/AppKernerl.php
public function registerBundles()
{
$bundles = array(
// ...
new Ibrows\XeditableBundle\IbrowsXeditableBundle(),
// ...
);
// ...
}
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')));
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.