Commit c593ed33 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Correction sur le formulaire d'édition de l'intervenant pour éviter les champs grisés (#67226)

parent e81087c9
Loading
Loading
Loading
Loading
Loading
+1 −1
Changes for module/Application/src/Hydrator/GenericHydrator.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -196,7 +196,7 @@ class GenericHydrator implements HydratorInterface

    public function setReadOnly(string $element, bool $readOnly = true)
    {
        $this->spec[$element]['readOnly'] = $readOnly;
        $this->spec[$element]['readonly'] = $readOnly;
    }


+4 −0
Changes for module/Intervenant/src/Controller/IntervenantController.php: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -373,6 +373,10 @@ class IntervenantController extends AbstractController
                        }
                    }

                    if ($request->isXmlHttpRequest()) {
                        return $this->redirect()->toRoute('intervenant/saisir', ['intervenant' => $intervenant->getId()]);
                    }

                    return $this->redirect()->toRoute('intervenant/voir', ['intervenant' => $intervenant->getId()], ['query' => ['tab' => 'edition']]);
                } catch (\Exception $e) {
                    $errors[] = $this->translate($e);
+18 −5
Changes for module/Intervenant/src/Form/EditionForm.php: 18 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ class EditionForm extends AbstractForm
        $hydrator->spec(Intervenant::class);
        $this->setHydrator($hydrator);
        $this->setAttribute('action', $this->getCurrentUrl());
        $this->setAttribute('class', 'form-intervenant-edition no-intranavigation');
        $this->setAttribute('class', 'form-intervenant-edition');


        $this->add([
@@ -495,14 +495,14 @@ class EditionForm extends AbstractForm
    public function activerEditionAvancee()
    {
        $elements = ['source', 'code', 'numeroPec', 'numeroInsee'];
        foreach ($this->getElements() as $element) {
            if (in_array($element->getName(), $elements)) {

        foreach ($elements as $elementName) {
            /** @var Element $element */
            $element = $this->get($elementName);
            $element->removeAttribute('readonly');
            $element->removeAttribute('disabled');
            $element->removeAttribute('title');
            }

            $this->getHydrator()->setReadOnly($elementName, false);
        }
    }

@@ -510,6 +510,19 @@ class EditionForm extends AbstractForm

    public function protection($object)
    {
        // Le formulaire pouvant être réutilisé, on retire d'abord les protections
        // appliquées lors d'un précédent bind avant de traiter l'objet courant.
        foreach ($this->getElements() as $element) {
            /** @var Element $element */
            $element->removeAttribute('readonly');
            $element->removeAttribute('disabled');
            $element->removeAttribute('title');

            if (array_key_exists($element->getName(), $this->hydratorElements)) {
                $this->getHydrator()->setReadOnly($element->getName(), false);
            }
        }

        if ($this->isReadOnly()) {

            foreach ($this->getElements() as $element) {