Commit 594cd6ee authored by Mat's avatar Mat

petites retouches sur Legume

parent 79842bd9
......@@ -102,7 +102,7 @@ class LegumeAPIController extends MasterAPIController
if ($form->isSubmitted() && $form->isValid())
{
$em->persist($legume);
//$em->persist($legume);
$em->flush();
return $this->api($legume);
}
......
......@@ -250,16 +250,7 @@
titleForm.textContent = 'Légume # ' + formatNumber(legumeId, 3);
form.querySelector('#legume_nom').value = json.nom;
let legumeFruit = form.querySelector('#legume_fruit');
for (let i = 0; i < legumeFruit.options.length; i++)
{
if (legumeFruit.options[i].value == json.fruit)
{
legumeFruit.selectedIndex = legumeFruit[i].index;
}
}
setFormSelectBoolValue('#legume_fruit', json.fruit);
form.querySelector('#legume_revente').value = json.revente;
form.querySelector('#legume_revente').checked = json.revente;
form.querySelector('#legume_description').value = json.description;
......
......@@ -202,6 +202,25 @@ function buildColorSquare(status, couleurs)
return '<i class="fas fa-square '+ fa + ' fa-fw"></i> ';
}
/*
* Attribuer une valeur par défaut à un select booleen
* @param: select, le sélecteur du select
* @param: value, la valeur qu'on attribue
*/
function setFormSelectBoolValue(select, value)
{
let field = form.querySelector(select);
for (let i = 0; i < field.options.length; i++)
{
if (field.options[i].value == value)
{
field.selectedIndex = field[i].index;
}
}
}
/*
* F O N C T I O N S A J A X
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment