Commit c354d649 authored by Théo GUILLON's avatar Théo GUILLON

Correction : condition sur les champs

Correction : enregistrement des valeurs des checkboxes
parent 20633073
......@@ -714,7 +714,15 @@ class WebdpoFiche extends AppModel {
if (is_array($data_merge[$fieldCondition['ifTheField']])) {
// champ checkbox, multi-select
if (in_array(substr($fieldCondition['hasValue'], -1), $data_merge[$fieldCondition['ifTheField']])){
$goodCondition = false;
foreach ($data_merge[$fieldCondition['ifTheField']] as $valueSelected) {
if (in_array($fieldCondition['ifTheField'].$valueSelected, $fieldCondition['hasValue'])) {
$goodCondition = true;
}
}
if ($goodCondition === true) {
$valueCondition = $fieldCondition['mustBe'];
} else {
$valueCondition = $fieldCondition['ifNot'];
......
......@@ -134,7 +134,6 @@ $line = 1;
case 'checkboxes':
echo $this->WebcilForm->input('WebdpoFiche.'.$options['name'], [
'id' => $options['name'],
'name' => $options['name'],
'label' => [
'text' => $options['label'],
'class' => 'col-md-4',
......@@ -323,15 +322,19 @@ $line = 1;
shownHideField(value['ifNot'], value['thenTheField']);
});
$.each($(valueIfTheField).val(), function (k, v) {
if (jQuery.inArray(v, value['hasValue']) !== -1 &&
$(valueIfTheField).parent().parent().css('display') !== 'none'
) {
shownHideField(value['mustBe'], value['thenTheField'])
} else {
shownHideField(value['ifNot'], value['thenTheField']);
}
});
if ($(valueIfTheField).parent().parent().css('display') !== 'none') {
$.each($(valueIfTheField).val(), function (k, v) {
if (jQuery.inArray(v, value['hasValue']) !== -1 &&
$(valueIfTheField).parent().parent().css('display') !== 'none'
) {
shownHideField(value['mustBe'], value['thenTheField'])
} else {
shownHideField(value['ifNot'], value['thenTheField']);
}
});
} else {
shownHideField(value['ifNot'], value['thenTheField']);
}
} else {
// Champ deroulant
......@@ -406,15 +409,17 @@ $line = 1;
shownHideField(value['ifNot'], value['thenTheField']);
});
if ($('#'+value['hasValue']).prop("checked") === true && $(valueIfTheField).parent().parent().css('display') != 'none') {
if ($('#'+value['hasValue']).prop("checked") === true &&
$(valueIfTheField).parent().parent().css('display') !== 'none'
) {
shownHideField(value['mustBe'], value['thenTheField'])
} else {
shownHideField(value['ifNot'], value['thenTheField']);
}
$('input[name ="'+value['ifTheField']+'[]"]').change(function() {
$('input[name ="data[WebdpoFiche]['+value['ifTheField']+'][]"]').change(function() {
let valueSelected = [];
$.each($('input[name ="'+value['ifTheField']+'[]"]:checked'), function(){
$.each($('input[name ="data[WebdpoFiche]['+value['ifTheField']+'][]"]:checked'), function(){
valueSelected.push($(this).attr('id'));
});
......
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