Skip to content
Snippets Groups Projects
Commit 441b2673 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

L'input Plus Custom est maintenant avec au moins un champ vide

parent a2595b66
No related branches found
No related tags found
No related merge requests found
Pipeline #36979 passed
...@@ -9,7 +9,9 @@ use UnicaenAutoform\Entity\Db\Champ; ...@@ -9,7 +9,9 @@ use UnicaenAutoform\Entity\Db\Champ;
$options = ($champ->getOptions() !== null) ?? explode(';', $champ->getOptions()); $options = ($champ->getOptions() !== null) ?? explode(';', $champ->getOptions());
$temp = ($reponse) ? explode(';', $reponse) : []; $temp = ($reponse) ? explode(';', $reponse) : [];
$temp = array_map(function ($s) { return "'".$s."'";}, $temp); $temp = array_map(function ($s) {
return "'" . $s . "'";
}, $temp);
$array = "[" . implode(",", $temp) . "]"; $array = "[" . implode(",", $temp) . "]";
?> ?>
...@@ -22,7 +24,8 @@ $array = "[" . implode(",", $temp) . "]"; ...@@ -22,7 +24,8 @@ $array = "[" . implode(",", $temp) . "]";
<?php endif; ?> <?php endif; ?>
<br> <br>
<span id="<?php echo $champ->getId(); ?>" class="ajouter btn btn-primary" onclick="ajouter_PlusCustom(<?php echo $champ->getId(); ?>, readOptions('<?php echo $champ->getOptions(); ?>'))"> <span id="<?php echo $champ->getId(); ?>" class="ajouter btn btn-primary"
onclick="ajouter_PlusCustom(<?php echo $champ->getId(); ?>, readOptions('<?php echo $champ->getOptions(); ?>'))">
<span class="icon icon-ajouter"></span> <span class="icon icon-ajouter"></span>
Ajouter Ajouter
</span> </span>
...@@ -44,25 +47,23 @@ $array = "[" . implode(",", $temp) . "]"; ...@@ -44,25 +47,23 @@ $array = "[" . implode(",", $temp) . "]";
let fields = readOptions(optionsText); let fields = readOptions(optionsText);
let reponses = '<?php echo $reponse; ?>'; let reponses = '<?php echo $reponse; ?>';
// console.log(fields);
let dictionnary = []; let dictionnary = [];
let blob = reponses.split('|'); let blob = reponses.split('|');
for (let i = 0; i < blob.length; i++) { for (let i = 0; i < blob.length; i++) {
dictionnary[i] = blob[i].split(';'); dictionnary[i] = blob[i].split(';');
} }
readOptions(optionsText); readOptions(optionsText);
let sid = <?php echo $champ->getId(); ?>; let sid = <?php echo $champ->getId(); ?>;
console.log('HERE'); console.log(dictionnary); console.log("Init du champ : " + sid);
console.log(dictionnary);
if (dictionnary !== ['']) { if (dictionnary !== ['']) {
for (let i = 0; i < dictionnary.length; i++) { for (let i = 0; i < dictionnary.length; i++) {
console.log(dictionnary[i]);
console.log(dictionnary[i][0]);
if (dictionnary[i][0] !== "") { if (dictionnary[i][0] !== "") {
ajouter_PlusCustom(sid, fields, dictionnary[i]); ajouter_PlusCustom(sid, fields, dictionnary[i]);
} else {
if (i === 0) ajouter_PlusCustom(sid, fields);
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment