unitkit / uk-common-bundle
library for form common functionality
v0.1.2
2017-09-01 13:56 UTC
Requires
- php: >=5.3.9
- symfony/symfony: 2.8.*
Requires (Dev)
- phpunit/phpunit: 3.7.*
This package is auto-updated.
Last update: 2020-07-19 15:47:05 UTC
README
Bundle for form common functionality.
Requires
- php: >=5.3.9
- symfony/symfony: 2.8.*
Install
Composer
#!console
> composer require unitkit/uk-common-bundle
Setup
app/AppKernel.php
#!php
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
new UnitKit\Common\UkCommonBundle()
);
return $bundles;
}
}
?>
Usage
Template
#!twig
{# base.html.twig #}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>{% block title %}{% endblock %}</title>
{% block stylesheets %}{% endblock %}
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
</head>
<body>
{% block body %}{% endblock %}
{% block javascripts %}
<script type="text/javascript" src="{{asset("web/bundles/uk-common-bundle/js/common.js")}}"></script>
{% endblock %}
</body>
</html>
Controller
#!php
<?php
use UnitKit\Common\UkCommonBundle\Controller\UkCommonController;
class CustomController extends UkCommonController
{
/**
* @Route("/form/")
*/
public function getForm(Request $request)
{
$form = $this->createForm(new CustomFormType(), null, array());
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid()){
// Save Data ...
}
return $this->renderResponse(
$request,
$form,
$this->render('AppBundle:Default:index.html.twig', array('form' => $form->createView()))
);
}
}
?>