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

Suppression : valeur par défault lors de la création d'un traitement

Correction : affichage valeur champ checkbox
parent ed02b7f9
......@@ -812,44 +812,6 @@ class FormulairesController extends AppController {
}
}
// valeur par défault
if ($this->request->params['action'] == 'add' && empty($this->request->data)) {
$fields['coresponsable'] = [
[
'Champ' => [
'type' => 'input',
'ligne' => 1,
'colonne' => 1,
'details' => '{"name":"nom_responsable_conjoint","placeholder":"Nom et prénom","label":"Nom et prénom du responsable conjoint","default":"","obligatoire":true}'
]
],
[
'Champ' => [
'type' => 'input',
'ligne' => 3,
'colonne' => 1,
'details' => '{"name":"structure_responsable_conjointe","placeholder":"Raison sociale","label":"Raison sociale de la structure conjointe","default":"","obligatoire":true}'
]
],
[
'Champ' => [
'type' => 'input',
'ligne' => 1,
'colonne' => 2,
'details' => '{"name":"email_responsable_conjoint","placeholder":"Adresse e-mail","label":"Adresse mail du responsable conjoint","default":"","obligatoire":true}'
]
],
[
'Champ' => [
'type' => 'textarea',
'ligne' => 3,
'colonne' => 2,
'details' => '{"name":"adresse_structure_responsable_conjointe","placeholder":"Adresse postale","label":"Adresse de la structure conjointe","default":"","obligatoire":false}'
]
]
];
}
$this->request->data['Formulaire']['form-container-formulaire'] = $fields['formulaire'];
$this->request->data['Formulaire']['form-container-coresponsable'] = $fields['coresponsable'];
$this->request->data['Formulaire']['form-container-soustraitant'] = $fields['soustraitant'];
......
......@@ -123,11 +123,11 @@ class WebdpoSoustraitance extends AppModel
// On vérifie que les champs suplémentaite du formualaire ne soient pas obligatoire
if (isset($data[$this->alias]) && !empty($data[$this->alias])) {
$success = true;
foreach ($data[$this->alias] as $soustraitant_id => $soustraitancefield) {
foreach ($arraySoustraitanceFields as $arraySoustraitanceField) {
$details = json_decode($arraySoustraitanceField['Champ']['details'], true);
if ($details['obligatoire'] === true) {
if (in_array($arraySoustraitanceField['Champ']['type'], ['checkboxes', 'multi-select'])) {
if (empty($soustraitancefield[$details['name']])) {
$this->validate[$details['name']]['multiple'] = ['rule' => ['multiple', ['min' => 1]]];
......
......@@ -250,7 +250,8 @@ if (isset($this->validationErrors['WebdpoCoresponsable']) && !empty($this->valid
if (ifMultiSelect.length) {
$(fieldId + ' option[value="' + v + '"]').prop("selected", true);
} else {
$('#' + key + v).prop("checked", true);
console.log('#' + key + v);
$('#' + key + v + '[name="data[WebdpoCoresponsable]['+idSelect+']['+key+'][]"]').prop("checked", true);
}
});
} else {
......
......@@ -234,7 +234,7 @@ if (isset($this->validationErrors['WebdpoSoustraitance']) ) {
if (ifMultiSelect.length) {
$(fieldId + ' option[value="' + v + '"]').prop("selected", true);
} else {
$('#' + key + v).prop("checked", true);
$('#' + key + v + '[name="data[WebdpoSoustraitance]['+idSelect+']['+key+'][]"]').prop("checked", true);
}
});
} else {
......
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