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
Loading
Loading
Loading
Loading
Loading
+20 −19
Original line number Diff line number Diff line
@@ -9,7 +9,9 @@ use UnicaenAutoform\Entity\Db\Champ;

$options = ($champ->getOptions() !== null) ?? explode(';', $champ->getOptions());
$temp = ($reponse) ? explode(';', $reponse) : [];
$temp = array_map(function ($s) { return "'".$s."'";}, $temp);
$temp = array_map(function ($s) {
    return "'" . $s . "'";
}, $temp);
$array = "[" . implode(",", $temp) . "]";
?>

@@ -22,7 +24,8 @@ $array = "[" . implode(",", $temp) . "]";
    <?php endif; ?>

    <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>
        Ajouter
    </span>
@@ -44,25 +47,23 @@ $array = "[" . implode(",", $temp) . "]";
        let fields = readOptions(optionsText);
        let reponses = '<?php echo $reponse; ?>';

        // console.log(fields);

        let dictionnary = [];
        let blob = reponses.split('|');
        for (let i = 0; i < blob.length; i++) {
            dictionnary[i] = blob[i].split(';');
        }


        readOptions(optionsText);
        let sid = <?php echo $champ->getId(); ?>;

        console.log('HERE'); console.log(dictionnary);
        console.log("Init du champ : " + sid);
        console.log(dictionnary);
        if (dictionnary !== ['']) {
            for (let i = 0; i < dictionnary.length; i++) {
                console.log(dictionnary[i]);
                console.log(dictionnary[i][0]);
                if (dictionnary[i][0] !== "") {
                    ajouter_PlusCustom(sid, fields, dictionnary[i]);
                } else {
                    if (i === 0) ajouter_PlusCustom(sid, fields);
                }
            }
        }