Commit 72fc1ad7 authored by Théo GUILLON's avatar Théo GUILLON
Browse files

Ajout : préfix sur le nom de variable sur les ongles coresponsable et soustraitanc

parent d200a139
......@@ -531,6 +531,12 @@ class FormulairesController extends AppController {
$this->view = 'edit';
}
private function begnWith($str, $begnString)
{
$len = strlen($begnString);
return (substr($str, 0, $len) === $begnString);
}
private function saveFields($formulaire_id, $fields, $ongletChampCoresponsable = false, $ongletChampSoustraitant = false)
{
$success = true;
......@@ -581,7 +587,21 @@ class FormulairesController extends AppController {
break;
case 'name':
$sortie[$clef] = LettercaseFormattableBehavior::formatageVariable($val);
$formatName = LettercaseFormattableBehavior::formatageVariable($val);
if ($ongletChampCoresponsable === true && $ongletChampSoustraitant === false) {
if ($this->begnWith($formatName, 'coresponsable_') === false) {
$formatName = 'coresponsable_'.$formatName;
}
}
if ($ongletChampSoustraitant === true && $ongletChampCoresponsable === false) {
if ($this->begnWith($formatName, 'soustraitant_') === false) {
$formatName = 'soustraitant_'.$formatName;
}
}
$sortie[$clef] = $formatName;
break;
case 'options':
......
......@@ -1068,6 +1068,11 @@ let createForm = function(typeCreateForm) {
// On récupère le "Nom de variable" et on le vérifie
if ($(this).hasClass('nameForm')) {
newNameField = $(this).val();
if (newNameField.startsWith(typeCreateForm+'_') === false && typeCreateForm !== 'formulaire') {
newNameField = typeCreateForm + '_' + newNameField;
$(this).val(newNameField);
}
success = checkNewNameField(newNameField);
}
......
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