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

Correction : enregistrement des options sur les champs checkbox, radio, select, multi-select

Correction : rename attribute virtuel quand les champs sont obligatoire
parent bff6664a
......@@ -703,42 +703,42 @@ 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,"repeat":false}'
]
],
[
'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,"repeat":false}'
]
],
[
'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,"repeat":false}'
]
],
[
'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,"repeat":false}'
]
]
];
}
// 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,"repeat":false}'
// ]
// ],
// [
// '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,"repeat":false}'
// ]
// ],
// [
// '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,"repeat":false}'
// ]
// ],
// [
// '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,"repeat":false}'
// ]
// ]
// ];
// }
$this->set(compact('fields'));
}
......
......@@ -33,7 +33,7 @@ foreach ($champs as $key => $value) {
switch ($value['Champ']['type']) {
// Petit champ texte
case 'input':
echo '<div class="draggable form-group col-md-6 small-text" style="top:' . $line . 'px; ' . $colonne . '" virtual-data-required="'.$champObligatoire.'" virtual-data-repeat="'.$fieldRepeat.'">'
echo '<div class="draggable form-group col-md-6 small-text" style="top:' . $line . 'px; ' . $colonne . '" data-virtual-required="'.$champObligatoire.'" virtual-data-repeat="'.$fieldRepeat.'">'
. '<div class="col-md-4">'
. '<label>'
. '<span class="labeler">' . $details['label'] . '</span>'
......
......@@ -205,7 +205,7 @@ var createForm = function(typeCreateForm) {
case 'btn-radio-'+typeCreateForm:
newElement = jQuery(
'<div class="draggable form-group col-md-6 radios ui-selected" virtual-data-required="fieldRequired" style="left : 0px; top : ' + top + 'px;">' +
'<div class="draggable form-group col-md-6 radios ui-selected" data-virtual-required="fieldRequired" style="left : 0px; top : ' + top + 'px;">' +
'<div class="col-md-4">' +
'<label>' +
'<span class="labeler">' +
......@@ -379,7 +379,7 @@ var createForm = function(typeCreateForm) {
'</div>';
// @TODO
if ($(idContainer).find('.ui-selected').attr('virtual-data-required') === 'fieldRequired') {
if ($(idContainer).find('.ui-selected').attr('data-virtual-required') === 'fieldRequired') {
check = '<div class="checkbox">' +
'<label>' +
'<input type="checkbox" id="checkboxFieldRequired" class="obligForm" checked="true">' +
......@@ -701,10 +701,10 @@ var createForm = function(typeCreateForm) {
$('.labelForm').val() + '</span><span class="obligatoire"> *</span>'
);
$(idContainer).find('.ui-selected').attr('virtual-data-required', 'fieldRequired');
$(idContainer).find('.ui-selected').attr('data-virtual-required', 'fieldRequired');
} else {
$(idContainer).find('.ui-selected').find('label').html('<span class="labeler">' + $('.labelForm').val() + '</span>');
$(idContainer).find('.ui-selected').attr('virtual-data-required', 'fieldNotRequired');
$(idContainer).find('.ui-selected').attr('data-virtual-required', 'fieldNotRequired');
}
}
......@@ -771,10 +771,10 @@ var createForm = function(typeCreateForm) {
$('.labelForm').val() + '</span><span class="obligatoire"> *</span>'
);
$(idContainer).find('.ui-selected').attr('virtual-data-required', 'fieldRequired');
$(idContainer).find('.ui-selected').attr('data-virtual-required', 'fieldRequired');
} else {
$(idContainer).find('.ui-selected').find('label').html('<span class="labeler">' + $('.labelForm').val() + '</span>');
$(idContainer).find('.ui-selected').attr('virtual-data-required', 'fieldNotRequired');
$(idContainer).find('.ui-selected').attr('data-virtual-required', 'fieldNotRequired');
}
}
......
......@@ -78,7 +78,7 @@ $(document).ready(function () {
var option = [];
$(draggable).find('input').each(function () {
option.push($(draggable).attr('value'));
option.push($(this).attr('value'));
});
contenu['options'] = option;
......@@ -101,7 +101,7 @@ $(document).ready(function () {
var option = [];
$(draggable).find('input').each(function () {
option.push($(draggable).attr('value'));
option.push($(this).attr('value'));
});
contenu['options'] = option;
} else if ($(draggable).hasClass('deroulant')) {
......@@ -143,7 +143,7 @@ $(document).ready(function () {
var option = [];
$(draggable).find('option').each(function () {
option.push($(draggable).attr('value'));
option.push($(this).attr('value'));
});
contenu['options'] = option;
......@@ -154,7 +154,7 @@ $(document).ready(function () {
contenu['default'] = valuesMultiSelectDefault;
}
if ($(draggable).attr('virtual-data-required') === 'fieldRequired') {
if ($(draggable).attr('data-virtual-required') === 'fieldRequired') {
contenu['obligatoire'] = true;
} else {
contenu['obligatoire'] = false;
......
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