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

Correction : enregistrement de valeur par défault

Correction : affichage des valeurs par default
parent a67c9d1b
......@@ -124,16 +124,18 @@ foreach ($champs as $key => $value) {
.'<div class="col-md-8 contentCheckbox">'
.'<input id="'.$details['name'].'" type="hidden" name="'.$details['name'].'" value="">';
foreach ($details['options'] as $key => $val) {
$checkbox_id = $details['name'].$key;
$checked = "";
if (isset($details['default'])) {
if (in_array($details['name'].$key, $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.'">'
. '<input id="'.$checkbox_id.'" class="champNomVariableReadonly" type="checkbox" '.$checked.' name="'.$details['name'].'" value="'.$key.'">'
.'<label for="'.$checkbox_id.'">'
.$val
.'</label>'
.'</div>';
......@@ -160,7 +162,7 @@ foreach ($champs as $key => $value) {
foreach ($details['options'] as $key => $val) {
$checked = "";
if (isset($details['default'])) {
if ($details['default'] === $details['name'].$key) {
if ($details['default'] === $val) {
$checked = "checked";
}
}
......@@ -191,7 +193,7 @@ foreach ($champs as $key => $value) {
foreach ($details['options'] as $key => $val) {
$selected = "";
if (isset($details['default'])) {
if ($details['default'] === $details['name'].$key) {
if ($details['default'] == $key) {
$selected = "selected";
}
}
......@@ -219,7 +221,7 @@ foreach ($champs as $key => $value) {
foreach ($details['options'] as $key => $val) {
$selected = "";
if (isset($details['default'])) {
if (in_array($details['name'].$key, $details['default'])) {
if (in_array($key, $details['default'])) {
$selected = 'selected';
}
}
......
......@@ -190,7 +190,12 @@
});
} else {
$(idContainer).find('input[name ="'+idFieldConditionCreated+'"], option[name ="'+idFieldConditionCreated+'"]').each(function () {
var option = $(this).attr('value');
if ($(this).attr('type') == 'checkbox') {
var option = $(this).next('label').text();
} else {
var option = $(this).attr('value');
}
var id = $(this).attr('id');
if (option && id) {
......
......@@ -551,6 +551,14 @@ var createForm = function(typeCreateForm) {
idListeDesValeurs = 'option-checkbox';
classListeValeur = 'checkboxForm';
$(idContainer).find('.ui-selected').find(findType).each(function () {
if (list === '') {
list = list + $(this).next('label').text();
} else {
list = list + '\n' + $(this).next('label').text();
}
});
} else if (object.hasClass('radios')) {
champId = 'name-radios-'+typeCreateForm;
......@@ -566,15 +574,15 @@ var createForm = function(typeCreateForm) {
'Champ obligatoire' +
'</label>' +
'</div>';
}
$(idContainer).find('.ui-selected').find(findType).each(function () {
if (list === '') {
list = list + $(this).val();
} else {
list = list + '\n' + $(this).val();
}
});
$(idContainer).find('.ui-selected').find(findType).each(function () {
if (list === '') {
list = list + $(this).val();
} else {
list = list + '\n' + $(this).val();
}
});
}
}
if (object.is('.deroulant, .multi-select')) {
......@@ -1178,7 +1186,7 @@ var createForm = function(typeCreateForm) {
objet = objet + '<input id="'+newNameField+'" type="hidden" name="'+newNameField+'" value="">'
$.each(newOptionsField, function (index, value) {
objet = objet + '<div class="checkbox">' +
'<input id="'+newNameField+index+'" type="checkbox" name="'+newNameField+'" value="'+value+'">' +
'<input id="'+newNameField+index+'" type="checkbox" name="'+newNameField+'" value="'+index+'">' +
'<label for="'+newNameField+index+'">' +
value +
'</label>' +
......
......@@ -100,13 +100,15 @@ $(document).ready(function () {
options = [];
$(draggable).find('input[type="checkbox"]').each(function () {
options.push($(this).attr('value'));
// options.push($(this).attr('value'));
options.push($(this).next('label').text());
});
objFieldDetails['options'] = options;
var valuesCheckboxesDefault = [];
$('input[name="'+fieldNameCheckboxes+'"]:checked').each(function(key, value) {
valuesCheckboxesDefault.push(this.id);
// valuesCheckboxesDefault.push(this.id);
valuesCheckboxesDefault.push(this.value);
});
objFieldDetails['default'] = valuesCheckboxesDefault;
......@@ -133,7 +135,8 @@ $(document).ready(function () {
var valuesRadiosDefault = '';
$('input[name="'+fieldNameRadios+'"]:checked').each(function() {
if (this.value != '') {
valuesRadiosDefault = this.id;
// valuesRadiosDefault = this.id;
valuesRadiosDefault = this.value;
}
});
objFieldDetails['default'] = valuesRadiosDefault;
......@@ -162,7 +165,8 @@ $(document).ready(function () {
var valuesDeroulantDefault = '';
$('option[name="'+fieldNameDeroulant+'"]:checked').each(function() {
if (this.value != '') {
valuesDeroulantDefault = this.id;
// valuesDeroulantDefault = this.id;
valuesDeroulantDefault = this.value;
}
});
objFieldDetails['default'] = valuesDeroulantDefault;
......
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