From 4e272a877148d26e2cfda97282aa9541efbf3b67 Mon Sep 17 00:00:00 2001 From: nicrausaz <n.crausaz99@gmail.com> Date: Thu, 28 Feb 2019 15:07:18 +0100 Subject: [PATCH] fix dyn inputs --- canapEPFL/script.js | 2 +- .../templates/formParts/edit/trainings.php | 20 +++++++++++++++++++ .../templates/formParts/new/proactivities.php | 10 ++++++---- .../templates/formParts/new/scolarity.php | 10 ++++++---- .../templates/formParts/new/trainings.php | 6 ++++-- 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/canapEPFL/script.js b/canapEPFL/script.js index 598ffaa..f31e8c0 100644 --- a/canapEPFL/script.js +++ b/canapEPFL/script.js @@ -51,7 +51,7 @@ function initDateChecker() { } function addChildren(parentId, maxItems, childTemplate, addButtonId) { - var i = $(parentId + ' > tbody').children().length + 1; + var i = $(parentId + ' > tbody').children().length; if (i < maxItems) { var fullTemplate = childTemplate.replace(/\{(.*?)\}/g, i); $(parentId).append(fullTemplate); diff --git a/canapEPFL/templates/formParts/edit/trainings.php b/canapEPFL/templates/formParts/edit/trainings.php index e69de29..bb9d8ec 100644 --- a/canapEPFL/templates/formParts/edit/trainings.php +++ b/canapEPFL/templates/formParts/edit/trainings.php @@ -0,0 +1,20 @@ +<?php + $trainings = getTrainingById($pdo, $current_post['applicant_id']); +?> +<table id="stages"> + <tr> + <th>Métier</th> + <th>Entreprise</th> + </tr> + <?php foreach ($trainings as $key => $training) { $i = $key + 1; ?> + <tr> + <td> + <input type="text" class="form-control" name="activiteStage<?php echo $i ?>" placeholder="Métier" value="<?= $training['training_job'] ?>" > + </td> + <td> + <input type="text" class="form-control" name="entrepriseStage<?php echo $i ?>" placeholder="Entreprise" value="<?= $training['training_company'] ?>" > + </td> + </tr> + <?php } ?> +</table> +<button type="button" class="btn btn-primary btn-sm mt-3 mb-2" id="addStage">Ajouter une ligne</button> \ No newline at end of file diff --git a/canapEPFL/templates/formParts/new/proactivities.php b/canapEPFL/templates/formParts/new/proactivities.php index ce91735..7015e8c 100644 --- a/canapEPFL/templates/formParts/new/proactivities.php +++ b/canapEPFL/templates/formParts/new/proactivities.php @@ -1,19 +1,21 @@ <table id="activites"> + <tr> + <th>Employeur</th> + <th>Lieu</th> + <th>Activité</th> + <th>Années</th> + </tr> <tr> <td> - <label for="employeurPro1">Employeur</label> <input type="text" class="form-control" name="employeurPro1" placeholder="Employeur" value="<?php echo $_SESSION['postedForm']['employeurPro1'] != '' ? $_SESSION['postedForm']['employeurPro1'] : ''; ?>"/> </td> <td> - <label for="lieuPro1">Lieu</label> <input type="text" class="form-control" name="lieuPro1" placeholder="Lieu" value="<?php echo $_SESSION['postedForm']['lieuPro1'] != '' ? $_SESSION['postedForm']['lieuPro1'] : ''; ?>"/> </td> <td> - <label for="activitePro1">Activité</label> <input type="text" class="form-control" name="activitePro1" placeholder="Activité" value="<?php echo $_SESSION['postedForm']['activitePro1'] != '' ? $_SESSION['postedForm']['activitePro1'] : ''; ?>"/> </td> <td> - <label for="anneesPro1">Années</label> <input type="text" class="form-control" name="anneesPro1" placeholder="de-à (années)" value="<?php echo $_SESSION['postedForm']['anneesPro1'] != '' ? $_SESSION['postedForm']['anneesPro1'] : ''; ?>"/> </td> </tr> diff --git a/canapEPFL/templates/formParts/new/scolarity.php b/canapEPFL/templates/formParts/new/scolarity.php index edad607..abb251a 100644 --- a/canapEPFL/templates/formParts/new/scolarity.php +++ b/canapEPFL/templates/formParts/new/scolarity.php @@ -1,19 +1,21 @@ <table id="scolaire"> + <tr> + <th>Ecole</th> + <th>Lieu</th> + <th>Niveau</th> + <th>Années</th> + </tr> <tr> <td> - <label for="ecole1">Ecole</label> <input type="text" name="ecole1" placeholder="Ecole *" class="form-control" value="<?php echo $_SESSION['postedForm']['ecole1'] != '' ? $_SESSION['postedForm']['ecole1'] : ''; ?>" data-required/> </td> <td> - <label for="lieuEcole1">Lieu</label> <input type="text" name="lieuEcole1" placeholder="Lieu *" class="form-control" value="<?php echo $_SESSION['postedForm']['lieuEcole1'] != '' ? $_SESSION['postedForm']['lieuEcole1'] : ''; ?>" data-required/> </td> <td> - <label for="niveauEcole1">Niveau</label> <input type="text" name="niveauEcole1" placeholder="Niveau *" class="form-control" value="<?php echo $_SESSION['postedForm']['niveauEcole1'] != '' ? $_SESSION['postedForm']['niveauEcole1'] : ''; ?>" data-required/> </td> <td> - <label for="anneesEcole1">Années</label> <input type="text" name="anneesEcole1" placeholder="de-à (années) *" class="form-control" value="<?php echo $_SESSION['postedForm']['anneesEcole1'] != '' ? $_SESSION['postedForm']['anneesEcole1'] : ''; ?>" data-required/> </td> </tr> diff --git a/canapEPFL/templates/formParts/new/trainings.php b/canapEPFL/templates/formParts/new/trainings.php index 3430f8e..7841882 100644 --- a/canapEPFL/templates/formParts/new/trainings.php +++ b/canapEPFL/templates/formParts/new/trainings.php @@ -1,11 +1,13 @@ <table id="stages"> + <tr> + <th>Métier</th> + <th>Entreprise</th> + </tr> <tr> <td> - <label for="activiteStage1">Métier</label> <input type="text" name="activiteStage1" class="form-control" placeholder="Métier" value="<?php echo $_SESSION['postedForm']['activiteStage1'] != '' ? $_SESSION['postedForm']['activiteStage1'] : ''; ?>"> </td> <td> - <label for="entrepriseStage1">Entreprise</label> <input type="text" name="entrepriseStage1" class="form-control" placeholder="Entreprise" value="<?php echo $_SESSION['postedForm']['entrepriseStage1'] != '' ? $_SESSION['postedForm']['entrepriseStage1'] : ''; ?>"> </td> </tr> -- GitLab