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

Correction : affichage des conditions pour le champ "checkboxes"

Modification : de la création d'un champ de type "checkboxes"
parent 6ee5ea0b
......@@ -580,20 +580,20 @@ class FormulairesController extends AppController {
}
break;
case 'conditions':
debug($val);
$conditions = (array)json_decode($val);
debug($conditions);
foreach ($conditions as $key => $condition) {
debug($condition);
$conditionValues = (array)json_decode($condition);
debug($conditionValues);
}
die;
break;
// case 'conditions':
// debug($val);
//
// $conditions = (array)json_decode($val);
// debug($conditions);
// foreach ($conditions as $key => $condition) {
// debug($condition);
//
// $conditionValues = (array)json_decode($condition);
// debug($conditionValues);
// }
// die;
//
// break;
default:
$sortie[$clef] = $val;
......
......@@ -103,25 +103,30 @@ foreach ($champs as $key => $value) {
case 'checkboxes':
echo '<div class="draggable form-group col-md-6 checkboxes" style="top: '.$line.'px; '.$colonne.'" data-virtual-required="'.$champObligatoire.'">'
.'<div class="input select">'
.'<label class="col-md-4">'
.'<label for="'.$details['name'].'" class="col-md-4">'
.'<span class="labeler">'.$details['label'].'</span>'
. ($details['obligatoire'] ? '<span class="obligatoire"> *</span>' : '')
.'</label>';
echo '<div class="col-md-8 contentCheckbox">';
foreach ($details['options'] as $key => $val) {
$checked = "";
if (isset($details['default'])) {
if (in_array($key, $details['default'])) {
$checked = "checked";
.'</label>'
.'<div class="col-md-8 contentCheckbox">'
.'<input id="'.$details['name'].'" type="hidden" name="'.$details['name'].'" value="">';
foreach ($details['options'] as $key => $val) {
$checked = "";
if (isset($details['default'])) {
if (in_array($key, $details['default'])) {
$checked = "checked";
}
}
echo '<div class="checkbox">'
. '<input id="'.$details['name'].$key.'" class="champNomVariableReadonly" type="checkbox" '.$checked.' name="'.$details['name'].'" value="'.$val.'">'
.'<label for="'.$details['name'].$key.'">'
.$val
.'</label>'
.'</div>';
}
}
echo '<div class="checkbox">'
. '<input id="'.$key.'" class="champNomVariableReadonly" type="checkbox" '.$checked.' name="'.$details['name'].'" value="'.$val.'"><label for="x'.$key.'">'.$val.'</label></div>';
}
echo '</div>
</div>
</div>';
echo '</div>'
.'</div>'
.'</div>';
break;
......
......@@ -326,6 +326,7 @@
$('#modalAddCondtion').on('hidden.bs.modal', function () {
hideAllFields();
$('#ifTheField option').slice(3).remove();
$('#ifTheField').val('');
})
});
......
......@@ -218,10 +218,10 @@ var createForm = function(typeCreateForm) {
'Cases à cocher' +
'</span>' +
'</label>' +
'</div>' +
'<div class="col-md-8 contentCheckbox">' +
'<div class="checkbox">'+
'<div class="col-md-8 contentCheckbox">' +
'<div class="checkbox">'+
'Aucune option sélectionnée'+
'</div>' +
'</div>' +
'</div>' +
'</div>'
......@@ -440,7 +440,15 @@ var createForm = function(typeCreateForm) {
// }
// }
if ( (object.hasClass('small-text')) || (object.hasClass('long-text')) || (object.hasClass('date')) ) {
if (object.is('.small-text, .long-text, .date, .checkboxes, .radios, .deroulant, .multi-select')) {
// Ecriture des conditions dans les options du champs
conditions = $(idContainer).find('.ui-selected').attr('data-virtual-conditions');
if (conditions) {
displayConditions = writeConditionsInOption(conditions);
}
}
if (object.is('.small-text, .long-text, .date')) {
var attrNameNomDeVariable = null,
classNameNomDeVariableRequired = '',
attrPlaceholderAideSaisie = null,
......@@ -448,7 +456,7 @@ var createForm = function(typeCreateForm) {
forPlaceholderAideSaisie = null,
placeholderAideSaisieReadonly = '';
if ( (object.hasClass('small-text')) || (object.hasClass('date')) ) {
if (object.is('.small-text, .date')) {
findType = 'input';
if (object.hasClass('small-text')) {
......@@ -484,11 +492,6 @@ var createForm = function(typeCreateForm) {
readonly = "readonly='readonly'";
}
conditions = $(idContainer).find('.ui-selected').attr('data-virtual-conditions');
if (conditions) {
displayConditions = writeConditionsInOption(conditions);
}
options = jQuery('' +
'<div class="col-md-12">' +
'<div class="col-md-3">' +
......@@ -524,7 +527,7 @@ var createForm = function(typeCreateForm) {
);
}
if ( (object.hasClass('checkboxes')) || (object.hasClass('radios')) || (object.hasClass('deroulant')) || (object.hasClass('multi-select')) ) {
if (object.is('.checkboxes, .radios, .deroulant, .multi-select')) {
var list = '',
nom = '',
classListeValeur = '',
......@@ -532,7 +535,7 @@ var createForm = function(typeCreateForm) {
forLabelNomDuChamp = '',
idListeDesValeurs = '';
if ( (object.hasClass('checkboxes')) || (object.hasClass('radios')) ) {
if (object.is('.checkboxes, .radios')) {
findType = 'input';
if (object.hasClass('checkboxes')) {
......@@ -562,7 +565,7 @@ var createForm = function(typeCreateForm) {
}
}
if ( (object.hasClass('deroulant')) || (object.hasClass('multi-select')) ) {
if (object.is('.deroulant, .multi-select')) {
findType = 'option';
if (object.hasClass('deroulant')) {
......@@ -634,11 +637,12 @@ var createForm = function(typeCreateForm) {
'</div>' +
check +
'</div>' +
displayConditions +
btnGoupsTrashApplicable
);
}
if ( (object.hasClass('title')) || (object.hasClass('help')) ) {
if (object.is('.title, .help')) {
var classContenu = '';
var valueContenu = null;
var labelForContenu = '';
......@@ -884,6 +888,11 @@ var createForm = function(typeCreateForm) {
var mustBe = '';
var ifNot = '';
if (!hasValue) {
var val_id = $('input[value="'+value['hasValue']+'"]').attr('id');
hasValue = $('label[for="'+val_id+'"]').text();
}
if (value['mustBe'] == 'shown') {
mustBe = 'afficher';
} else {
......@@ -1049,10 +1058,11 @@ var createForm = function(typeCreateForm) {
// Attribution les valeurs au champ "Cases à cocher"
if ($(this).hasClass('checkboxes')) {
objet = objet + '<input id="'+newNameField+'" type="hidden" name="'+newNameField+'" value="">'
$.each(newOptionsField, function (index, value) {
objet = objet + '<div class="checkbox">' +
'<input id="'+index+'" type="checkbox" name="'+newNameField+'" value="'+value+'">' +
'<label>' +
'<input id="'+newNameField+index+'" type="checkbox" name="'+newNameField+'" value="'+value+'">' +
'<label for="'+newNameField+index+'">' +
value +
'</label>' +
'</div>';
......
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