Material types edition : better form

master
Julien Rosset 2 months ago
parent 4e299630b6
commit 037806df82

@ -24,8 +24,9 @@ class MaterialTypeController extends AbstractController {
private readonly MaterialTypeRepository $materialTypeRepository; private readonly MaterialTypeRepository $materialTypeRepository;
/** /**
* Initialisation * Initialization
* *
* @param EntityManagerInterface $entityManager The entity manager
* @param MaterialTypeRepository $materialTypeRepository The material type repository * @param MaterialTypeRepository $materialTypeRepository The material type repository
*/ */
public function __construct (EntityManagerInterface $entityManager, MaterialTypeRepository $materialTypeRepository) { public function __construct (EntityManagerInterface $entityManager, MaterialTypeRepository $materialTypeRepository) {
@ -69,7 +70,8 @@ class MaterialTypeController extends AbstractController {
} }
return $this->render('Config/MaterialType/Edit.html.twig', [ return $this->render('Config/MaterialType/Edit.html.twig', [
'form' => $form->createView(), 'materialType' => $materialType,
'form' => $form->createView(),
]); ]);
} }

@ -3,15 +3,30 @@
namespace App\Form\Config; namespace App\Form\Config;
use App\Entity\MaterialType; use App\Entity\MaterialType;
use App\Form\Type\CancelButtonType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\RouterInterface;
/** /**
* The form for editing a material type * The form for editing a material type
*/ */
class MaterialTypeEditForm extends AbstractType { class MaterialTypeEditForm extends AbstractType {
/**
* @var RouterInterface The router service
*/
private readonly RouterInterface $router;
/**
* Initialization
*
* @param RouterInterface $router The router service
*/
public function __construct (RouterInterface $router) {
$this->router = $router;
}
/** /**
* @inheritDoc * @inheritDoc

@ -1,8 +1,15 @@
{% extends 'base.html.twig' %} {% extends 'base.html.twig' %}
{% block title %}Modification type de matériau - {{ parent() }}{% endblock %} {% block title %}{% if materialType.id is null %}Création {% else %}Modification{% endif %} type de matériau - {{ parent() }}{% endblock %}
{% block mainContent %} {% block mainContent %}
<h1>Modification type de matériau</h1> <h1>
{% if materialType.id is null %}
Création nouveau type de matériau
{% else %}
Modification du type de matériau "{{ materialType.name }}"
{% endif %}
</h1>
{{ form(form) }} {{ form(form) }}
<a href="{{ path('config_materialType_list') }}" class="btn btn-danger">Annuler</a>
{% endblock %} {% endblock %}

Loading…
Cancel
Save