nicer cruds
This commit is contained in:
parent
d5ef71f734
commit
c66aa69037
@ -11,11 +11,14 @@
|
||||
{% block navigation %}
|
||||
{% include 'default/login-choices.html.twig' %}
|
||||
{% endblock %}
|
||||
{% block body %}
|
||||
<div class="well">
|
||||
Votre caisse mobile en ligne
|
||||
</div>
|
||||
{% endblock %}
|
||||
<div class="container">
|
||||
|
||||
{% block body %}
|
||||
<div class="well">
|
||||
Votre caisse mobile en ligne
|
||||
</div>
|
||||
{% endblock %}
|
||||
</div>
|
||||
{% block javascripts %}
|
||||
<script src="{{ asset('build/app.js') }}"></script>
|
||||
{% endblock %}
|
||||
|
@ -4,10 +4,27 @@
|
||||
<div class="well">
|
||||
<div class="login-choices">
|
||||
{% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
|
||||
{{ 'layout.logged_in_as'|trans({'%username%': app.user.username}, 'FOSUserBundle') }} |
|
||||
<a class="btn btn-default" href="{{ path('fos_user_security_logout') }}">
|
||||
{{ 'layout.logout'|trans({}, 'FOSUserBundle') }}
|
||||
</a>
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<a class="btn btn-default" href="{{ path('homepage') }}">
|
||||
|
||||
<i class="fa fa-home"></i>
|
||||
Caisse
|
||||
</a>
|
||||
<a class="btn btn-default" href="{{ path('dashboard') }}">
|
||||
<i class="fa fa-list"></i>
|
||||
Dashboard
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-6 text-right">
|
||||
{{ 'layout.logged_in_as'|trans({'%username%': app.user.username}, 'FOSUserBundle') }} |
|
||||
<a class="btn btn-default" href="{{ path('fos_user_security_logout') }}">
|
||||
{{ 'layout.logout'|trans({}, 'FOSUserBundle') }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{% else %}
|
||||
<a class="btn btn-default btn-block btn-twitter" href="{{ hwi_oauth_login_url('google') }}">
|
||||
<i class="fa fa-google"></i>
|
||||
|
21
app/Resources/views/festival/edit.html.twig
Normal file
21
app/Resources/views/festival/edit.html.twig
Normal file
@ -0,0 +1,21 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Festival edit</h1>
|
||||
|
||||
{{ form_start(edit_form) }}
|
||||
{{ form_widget(edit_form) }}
|
||||
<input type="submit" value="Edit" />
|
||||
{{ form_end(edit_form) }}
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('festival_index') }}">Back to the list</a>
|
||||
</li>
|
||||
<li>
|
||||
{{ form_start(delete_form) }}
|
||||
<input type="submit" value="Delete">
|
||||
{{ form_end(delete_form) }}
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
41
app/Resources/views/festival/index.html.twig
Normal file
41
app/Resources/views/festival/index.html.twig
Normal file
@ -0,0 +1,41 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Festivals list</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Name</th>
|
||||
<th>Datecreation</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for festival in festivals %}
|
||||
<tr>
|
||||
<td><a href="{{ path('festival_show', { 'id': festival.id }) }}">{{ festival.id }}</a></td>
|
||||
<td>{{ festival.name }}</td>
|
||||
<td>{% if festival.dateCreation %}{{ festival.dateCreation|date('Y-m-d H:i:s') }}{% endif %}</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('festival_show', { 'id': festival.id }) }}">show</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ path('festival_edit', { 'id': festival.id }) }}">edit</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('festival_new') }}">Create a new festival</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
16
app/Resources/views/festival/new.html.twig
Normal file
16
app/Resources/views/festival/new.html.twig
Normal file
@ -0,0 +1,16 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Festival creation</h1>
|
||||
|
||||
{{ form_start(form) }}
|
||||
{{ form_widget(form) }}
|
||||
<input type="submit" value="Create" />
|
||||
{{ form_end(form) }}
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('festival_index') }}">Back to the list</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
36
app/Resources/views/festival/show.html.twig
Normal file
36
app/Resources/views/festival/show.html.twig
Normal file
@ -0,0 +1,36 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Festival</h1>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<td>{{ festival.id }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<td>{{ festival.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Datecreation</th>
|
||||
<td>{% if festival.dateCreation %}{{ festival.dateCreation|date('Y-m-d H:i:s') }}{% endif %}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('festival_index') }}">Back to the list</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ path('festival_edit', { 'id': festival.id }) }}">Edit</a>
|
||||
</li>
|
||||
<li>
|
||||
{{ form_start(delete_form) }}
|
||||
<input type="submit" value="Delete">
|
||||
{{ form_end(delete_form) }}
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
@ -62,7 +62,13 @@
|
||||
<div class="text-right">
|
||||
<h3 >Total: <strong>{{CurrentSellingTotal()}}€</strong></h3>
|
||||
<input type="number" id="paid_amount" ng-model="paidAmount">
|
||||
<div class="alert alert-success" ng-if="CurrentSellingTotal() - paidAmount <=0">
|
||||
<h3>Rendu: {{ CurrentSellingTotal() - paidAmount }}€</h3>
|
||||
</div>
|
||||
<div class="alert alert-warning" ng-if="CurrentSellingTotal() - paidAmount >0">
|
||||
<h3>il manque: {{ CurrentSellingTotal() - paidAmount }}€</h3>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{% endverbatim %}
|
||||
|
@ -9,10 +9,10 @@
|
||||
<a href="#caisse-now" data-toggle="tab">Caisse</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#categories" data-toggle="tab">Catégories</a>
|
||||
<a href="{{ path('productcategory_index') }}">Catégories</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#products" data-toggle="tab">Produits</a>
|
||||
<a href="{{ path('product_index') }}" data-toggle="tab">Produits</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#history" data-toggle="tab">Historique</a>
|
||||
|
21
app/Resources/views/product/edit.html.twig
Normal file
21
app/Resources/views/product/edit.html.twig
Normal file
@ -0,0 +1,21 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Product edit</h1>
|
||||
|
||||
{{ form_start(edit_form) }}
|
||||
{{ form_widget(edit_form) }}
|
||||
<input type="submit" value="Edit" />
|
||||
{{ form_end(edit_form) }}
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('product_index') }}">Back to the list</a>
|
||||
</li>
|
||||
<li>
|
||||
{{ form_start(delete_form) }}
|
||||
<input type="submit" value="Delete">
|
||||
{{ form_end(delete_form) }}
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
16
app/Resources/views/product/new.html.twig
Normal file
16
app/Resources/views/product/new.html.twig
Normal file
@ -0,0 +1,16 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Product creation</h1>
|
||||
|
||||
{{ form_start(form) }}
|
||||
{{ form_widget(form) }}
|
||||
<input type="submit" value="Create" />
|
||||
{{ form_end(form) }}
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('product_index') }}">Back to the list</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
44
app/Resources/views/product/show.html.twig
Normal file
44
app/Resources/views/product/show.html.twig
Normal file
@ -0,0 +1,44 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Product</h1>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<td>{{ product.id }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<td>{{ product.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Image</th>
|
||||
<td>{{ product.image }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Price</th>
|
||||
<td>{{ product.price }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Comment</th>
|
||||
<td>{{ product.comment }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('product_index') }}">Back to the list</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ path('product_edit', { 'id': product.id }) }}">Edit</a>
|
||||
</li>
|
||||
<li>
|
||||
{{ form_start(delete_form) }}
|
||||
<input type="submit" value="Delete">
|
||||
{{ form_end(delete_form) }}
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
21
app/Resources/views/productcategory/edit.html.twig
Normal file
21
app/Resources/views/productcategory/edit.html.twig
Normal file
@ -0,0 +1,21 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Productcategory edit</h1>
|
||||
|
||||
{{ form_start(edit_form) }}
|
||||
{{ form_widget(edit_form) }}
|
||||
<input type="submit" value="Edit" />
|
||||
{{ form_end(edit_form) }}
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('productcategory_index') }}">Back to the list</a>
|
||||
</li>
|
||||
<li>
|
||||
{{ form_start(delete_form) }}
|
||||
<input type="submit" value="Delete">
|
||||
{{ form_end(delete_form) }}
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
39
app/Resources/views/productcategory/index.html.twig
Normal file
39
app/Resources/views/productcategory/index.html.twig
Normal file
@ -0,0 +1,39 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Productcategories list</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Name</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for productCategory in productCategories %}
|
||||
<tr>
|
||||
<td><a href="{{ path('productcategory_show', { 'id': productCategory.id }) }}">{{ productCategory.id }}</a></td>
|
||||
<td>{{ productCategory.name }}</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('productcategory_show', { 'id': productCategory.id }) }}">show</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ path('productcategory_edit', { 'id': productCategory.id }) }}">edit</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('productcategory_new') }}">Create a new productCategory</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
16
app/Resources/views/productcategory/new.html.twig
Normal file
16
app/Resources/views/productcategory/new.html.twig
Normal file
@ -0,0 +1,16 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Productcategory creation</h1>
|
||||
|
||||
{{ form_start(form) }}
|
||||
{{ form_widget(form) }}
|
||||
<input type="submit" value="Create" />
|
||||
{{ form_end(form) }}
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('productcategory_index') }}">Back to the list</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
32
app/Resources/views/productcategory/show.html.twig
Normal file
32
app/Resources/views/productcategory/show.html.twig
Normal file
@ -0,0 +1,32 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Productcategory</h1>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<td>{{ productCategory.id }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<td>{{ productCategory.name }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('productcategory_index') }}">Back to the list</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ path('productcategory_edit', { 'id': productCategory.id }) }}">Edit</a>
|
||||
</li>
|
||||
<li>
|
||||
{{ form_start(delete_form) }}
|
||||
<input type="submit" value="Delete">
|
||||
{{ form_end(delete_form) }}
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
@ -3,3 +3,7 @@
|
||||
list-style-type: none;
|
||||
}
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
@ -5,132 +5,129 @@ namespace AppBundle\Controller;
|
||||
use AppBundle\Entity\ProductCategory;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;use Symfony\Component\HttpFoundation\Request;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Productcategory controller.
|
||||
*
|
||||
* @Route("productcategory")
|
||||
*/
|
||||
class ProductCategoryController extends Controller
|
||||
{
|
||||
/**
|
||||
* Lists all productCategory entities.
|
||||
*
|
||||
* @Route("/", name="productcategory_index")
|
||||
* @Method("GET")
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
class ProductCategoryController extends Controller {
|
||||
/**
|
||||
* Lists all productCategory entities.
|
||||
*
|
||||
* @Route("/", name="productcategory_index")
|
||||
* @Method("GET")
|
||||
*/
|
||||
public function indexAction() {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$productCategories = $em->getRepository('AppBundle:ProductCategory')->findAll();
|
||||
$productCategories = $em->getRepository( 'AppBundle:ProductCategory' )->findAll();
|
||||
|
||||
return $this->render('productcategory/index.html.twig', array(
|
||||
'productCategories' => $productCategories,
|
||||
));
|
||||
}
|
||||
return $this->render( 'productcategory/index.html.twig',
|
||||
[
|
||||
'productCategories' => $productCategories,
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new productCategory entity.
|
||||
*
|
||||
* @Route("/new", name="productcategory_new")
|
||||
* @Method({"GET", "POST"})
|
||||
*/
|
||||
public function newAction(Request $request)
|
||||
{
|
||||
$productCategory = new Productcategory();
|
||||
$form = $this->createForm('AppBundle\Form\ProductCategoryType', $productCategory);
|
||||
$form->handleRequest($request);
|
||||
/**
|
||||
* Creates a new productCategory entity.
|
||||
*
|
||||
* @Route("/new", name="productcategory_new")
|
||||
* @Method({"GET", "POST"})
|
||||
*/
|
||||
public function newAction( Request $request ) {
|
||||
$productCategory = new Productcategory();
|
||||
$form = $this->createForm( 'AppBundle\Form\ProductCategoryType', $productCategory );
|
||||
$form->handleRequest( $request );
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($productCategory);
|
||||
$em->flush();
|
||||
if ( $form->isSubmitted() && $form->isValid() ) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist( $productCategory );
|
||||
$em->flush();
|
||||
|
||||
return $this->redirectToRoute('productcategory_show', array('id' => $productCategory->getId()));
|
||||
}
|
||||
return $this->redirectToRoute( 'productcategory_show', [ 'id' => $productCategory->getId() ] );
|
||||
}
|
||||
|
||||
return $this->render('productcategory/new.html.twig', array(
|
||||
'productCategory' => $productCategory,
|
||||
'form' => $form->createView(),
|
||||
));
|
||||
}
|
||||
return $this->render( 'productcategory/new.html.twig',
|
||||
[
|
||||
'productCategory' => $productCategory,
|
||||
'form' => $form->createView(),
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds and displays a productCategory entity.
|
||||
*
|
||||
* @Route("/{id}", name="productcategory_show")
|
||||
* @Method("GET")
|
||||
*/
|
||||
public function showAction(ProductCategory $productCategory)
|
||||
{
|
||||
$deleteForm = $this->createDeleteForm($productCategory);
|
||||
/**
|
||||
* Finds and displays a productCategory entity.
|
||||
*
|
||||
* @Route("/{id}", name="productcategory_show")
|
||||
* @Method("GET")
|
||||
*/
|
||||
public function showAction( ProductCategory $productCategory ) {
|
||||
$deleteForm = $this->createDeleteForm( $productCategory );
|
||||
|
||||
return $this->render('productcategory/show.html.twig', array(
|
||||
'productCategory' => $productCategory,
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
));
|
||||
}
|
||||
return $this->render( 'productcategory/show.html.twig',
|
||||
[
|
||||
'productCategory' => $productCategory,
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a form to edit an existing productCategory entity.
|
||||
*
|
||||
* @Route("/{id}/edit", name="productcategory_edit")
|
||||
* @Method({"GET", "POST"})
|
||||
*/
|
||||
public function editAction(Request $request, ProductCategory $productCategory)
|
||||
{
|
||||
$deleteForm = $this->createDeleteForm($productCategory);
|
||||
$editForm = $this->createForm('AppBundle\Form\ProductCategoryType', $productCategory);
|
||||
$editForm->handleRequest($request);
|
||||
/**
|
||||
* Displays a form to edit an existing productCategory entity.
|
||||
*
|
||||
* @Route("/{id}/edit", name="productcategory_edit")
|
||||
* @Method({"GET", "POST"})
|
||||
*/
|
||||
public function editAction( Request $request, ProductCategory $productCategory ) {
|
||||
$deleteForm = $this->createDeleteForm( $productCategory );
|
||||
$editForm = $this->createForm( 'AppBundle\Form\ProductCategoryType', $productCategory );
|
||||
$editForm->handleRequest( $request );
|
||||
|
||||
if ($editForm->isSubmitted() && $editForm->isValid()) {
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
if ( $editForm->isSubmitted() && $editForm->isValid() ) {
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
return $this->redirectToRoute('productcategory_edit', array('id' => $productCategory->getId()));
|
||||
}
|
||||
return $this->redirectToRoute( 'productcategory_edit', [ 'id' => $productCategory->getId() ] );
|
||||
}
|
||||
|
||||
return $this->render('productcategory/edit.html.twig', array(
|
||||
'productCategory' => $productCategory,
|
||||
'edit_form' => $editForm->createView(),
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
));
|
||||
}
|
||||
return $this->render( 'productcategory/edit.html.twig',
|
||||
[
|
||||
'productCategory' => $productCategory,
|
||||
'edit_form' => $editForm->createView(),
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a productCategory entity.
|
||||
*
|
||||
* @Route("/{id}", name="productcategory_delete")
|
||||
* @Method("DELETE")
|
||||
*/
|
||||
public function deleteAction(Request $request, ProductCategory $productCategory)
|
||||
{
|
||||
$form = $this->createDeleteForm($productCategory);
|
||||
$form->handleRequest($request);
|
||||
/**
|
||||
* Deletes a productCategory entity.
|
||||
*
|
||||
* @Route("/{id}", name="productcategory_delete")
|
||||
* @Method("DELETE")
|
||||
*/
|
||||
public function deleteAction( Request $request, ProductCategory $productCategory ) {
|
||||
$form = $this->createDeleteForm( $productCategory );
|
||||
$form->handleRequest( $request );
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->remove($productCategory);
|
||||
$em->flush();
|
||||
}
|
||||
if ( $form->isSubmitted() && $form->isValid() ) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->remove( $productCategory );
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('productcategory_index');
|
||||
}
|
||||
return $this->redirectToRoute( 'productcategory_index' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a form to delete a productCategory entity.
|
||||
*
|
||||
* @param ProductCategory $productCategory The productCategory entity
|
||||
*
|
||||
* @return \Symfony\Component\Form\Form The form
|
||||
*/
|
||||
private function createDeleteForm(ProductCategory $productCategory)
|
||||
{
|
||||
return $this->createFormBuilder()
|
||||
->setAction($this->generateUrl('productcategory_delete', array('id' => $productCategory->getId())))
|
||||
->setMethod('DELETE')
|
||||
->getForm()
|
||||
;
|
||||
}
|
||||
/**
|
||||
* Creates a form to delete a productCategory entity.
|
||||
*
|
||||
* @param ProductCategory $productCategory The productCategory entity
|
||||
*
|
||||
* @return \Symfony\Component\Form\Form The form
|
||||
*/
|
||||
private function createDeleteForm( ProductCategory $productCategory ) {
|
||||
return $this->createFormBuilder()
|
||||
->setAction( $this->generateUrl( 'productcategory_delete', [ 'id' => $productCategory->getId() ] ) )
|
||||
->setMethod( 'DELETE' )
|
||||
->getForm();
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,10 @@ class ProductCategory {
|
||||
*/
|
||||
private $users;
|
||||
|
||||
public function __toString() {
|
||||
return $this->getName() . ' (' . count( $this->getProducts() ) . ' produits)';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
|
@ -6,31 +6,31 @@ use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class ProductType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('name')->add('image')->add('price')->add('comment')->add('category')->add('user');
|
||||
}/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'AppBundle\Entity\Product'
|
||||
));
|
||||
}
|
||||
class ProductType extends AbstractType {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm( FormBuilderInterface $builder, array $options ) {
|
||||
$builder->add( 'name' )->add( 'image',
|
||||
null,
|
||||
[ 'label' => 'URL pour image' ] )->add( 'price' )->add( 'comment' )->add( 'category' )->add( 'user' );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'appbundle_product';
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configureOptions( OptionsResolver $resolver ) {
|
||||
$resolver->setDefaults( [
|
||||
'data_class' => 'AppBundle\Entity\Product',
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBlockPrefix() {
|
||||
return 'appbundle_product';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user