Commit 3db91fd9 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Ajout dans le formulaire avec modification du formulaire dynamique

parent c6141f93
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ return [
                    'controller' => RessourceRhController::class,
                    'action' => [
                        'index',
                        'get-grades-json',
                    ],
                    'privileges' => [
                        RessourceRhPrivileges::AFFICHER,
@@ -400,6 +401,16 @@ return [
                        ],
                        'may_terminate' => false,
                        'child_routes' => [
                            'get-grades' => [
                                'type'  => Literal::class,
                                'options' => [
                                    'route'    => '/get-grades',
                                    'defaults' => [
                                        'controller' => RessourceRhController::class,
                                        'action'     => 'get-grades-json',
                                    ],
                                ],
                            ],
                            'ajouter' => [
                                'type'  => Literal::class,
                                'options' => [
+2 −2
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ class AgentController extends AbstractActionController
        }

        $vm = new ViewModel();
        $vm->setTemplate('application/default/default-form');
        $vm->setTemplate('application/agent/modifier');
        $vm->setVariables([
            'title' => 'Ajouter un agent',
            'form' => $form,
@@ -83,7 +83,7 @@ class AgentController extends AbstractActionController
        }

        $vm = new ViewModel();
        $vm->setTemplate('application/default/default-form');
        $vm->setTemplate('application/agent/modifier');
        $vm->setVariables([
            'title' => 'Modifier un agent',
            'form' => $form,
+20 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ use Application\Form\RessourceRh\CorrespondanceForm;
use Application\Service\RessourceRh\RessourceRhServiceAwareTrait;
use Zend\Http\Request;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\JsonModel;
use Zend\View\Model\ViewModel;

class RessourceRhController extends AbstractActionController {
@@ -626,4 +627,23 @@ class RessourceRhController extends AbstractActionController {
        $this->redirect()->toRoute('ressource-rh', [], [], true);
    }

    public function getGradesJsonAction()
    {
        $grades = $this->getRessourceRhService()->getGrades();

        $result = [];
        foreach ($grades as $grade) {
            $result[$grade->getId()] = [
                'id' => $grade->getId(),
                'corps' => $grade->getCorps()->getId(),
                'libelle' => $grade->getLibelle(),
            ];
        }
        $jm = new JsonModel(
            $result
        );
        return $jm;

    }

}
 No newline at end of file
+22 −0
Original line number Diff line number Diff line
@@ -29,6 +29,9 @@ class Agent {
    private $correspondance;
    /** @var Corps */
    private $corps;
    /** @var Grade */
    private $grade;


    /** @var string */
    private $missionsComplementaires;
@@ -226,6 +229,25 @@ class Agent {
        return $this;
    }

    /**
     * @return Grade
     */
    public function getGrade()
    {
        return $this->grade;
    }

    /**
     * @param Grade $grade
     * @return Agent
     */
    public function setGrade($grade)
    {
        $this->grade = $grade;
        return $this;
    }




}
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@
        <many-to-one target-entity="Application\Entity\Db\Corps" field="corps">
            <join-column name="corps" referenced-column-name="id" />
        </many-to-one>
        <many-to-one target-entity="Application\Entity\Db\Grade" field="grade">
            <join-column name="grade" referenced-column-name="id" />
        </many-to-one>

    </entity>
</doctrine-mapping>
Loading