diff --git a/src/Controller/Config/MaterialTypeController.php b/src/Controller/Config/MaterialTypeController.php index e6b6e51..9b778e7 100644 --- a/src/Controller/Config/MaterialTypeController.php +++ b/src/Controller/Config/MaterialTypeController.php @@ -24,8 +24,9 @@ class MaterialTypeController extends AbstractController { private readonly MaterialTypeRepository $materialTypeRepository; /** - * Initialisation + * Initialization * + * @param EntityManagerInterface $entityManager The entity manager * @param MaterialTypeRepository $materialTypeRepository The material type repository */ public function __construct (EntityManagerInterface $entityManager, MaterialTypeRepository $materialTypeRepository) { @@ -69,7 +70,8 @@ class MaterialTypeController extends AbstractController { } return $this->render('Config/MaterialType/Edit.html.twig', [ - 'form' => $form->createView(), + 'materialType' => $materialType, + 'form' => $form->createView(), ]); } diff --git a/src/Form/Config/MaterialTypeEditForm.php b/src/Form/Config/MaterialTypeEditForm.php index 020bee4..6267894 100644 --- a/src/Form/Config/MaterialTypeEditForm.php +++ b/src/Form/Config/MaterialTypeEditForm.php @@ -3,15 +3,30 @@ namespace App\Form\Config; use App\Entity\MaterialType; +use App\Form\Type\CancelButtonType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\Routing\RouterInterface; /** * The form for editing a material type */ 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 diff --git a/templates/Config/MaterialType/Edit.html.twig b/templates/Config/MaterialType/Edit.html.twig index 765bc3e..63f7205 100644 --- a/templates/Config/MaterialType/Edit.html.twig +++ b/templates/Config/MaterialType/Edit.html.twig @@ -1,8 +1,15 @@ {% 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 %} -