Skip to content

Commit

Permalink
fix(condition): fix inconsistency when checking question conditions
Browse files Browse the repository at this point in the history
fix #829
  • Loading branch information
btry committed Jan 2, 2018
1 parent f183091 commit a820e55
Show file tree
Hide file tree
Showing 5 changed files with 210 additions and 208 deletions.
2 changes: 1 addition & 1 deletion inc/fields.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public static function isVisible($id, $values) {
foreach ($questionConditions as $question_condition) {
$conditions[] = [
'logic' => $question_condition->getField('show_logic'),
'field' => $question_condition->getField('show_field'),
'field' => 'formcreator_field_' . $question_condition->getField('show_field'),
'operator' => $question_condition->getField('show_condition'),
'value' => $question_condition->getField('show_value')
];
Expand Down
9 changes: 6 additions & 3 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -914,8 +914,8 @@ class='formcreator_form form_horizontal'>";
}
}
echo Html::scriptBlock('$(function() {
formcreatorShowFields();
})');
formcreatorShowFields();
})');

// Show validator selector
if ($item->fields['validation_required'] > 0) {
Expand Down Expand Up @@ -1106,7 +1106,7 @@ public function saveForm($input) {
$valid = true;
$data = [];

// Validate form fields
// Prepare form fields for validation
$question = new PluginFormcreatorQuestion();
$found_questions = $question->getQuestionsFromForm($this->getID());
foreach ($found_questions as $id => $question) {
Expand All @@ -1125,7 +1125,10 @@ public function saveForm($input) {
} else {
$data['formcreator_field_' . $id] = '';
}
}

// Validate form fields
foreach ($found_questions as $id => $question) {
$className = 'PluginFormcreator' . ucfirst($question->getField('fieldtype')) . 'Field';

if (class_exists($className)) {
Expand Down
2 changes: 1 addition & 1 deletion js/scripts.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ function deleteTarget(items_id, token, target_id) {
var formcreatorQuestions = new Object();

function formcreatorChangeValueOf(field_id, value) {
formcreatorQuestions[field_id] = value;
formcreatorQuestions['formcreator_field_' + field_id] = value;
formcreatorShowFields();
}
function formcreatorAddValueOf(field_id, value) {
Expand Down
Loading

0 comments on commit a820e55

Please sign in to comment.