Skip to content

Commit 42d5fed

Browse files
committed
fix(condition): loss of condition on submit button
also improve questions dropdown to edit conditions Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent 92629fe commit 42d5fed

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

inc/condition.class.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,13 @@ public function getConditionHtml(array $input) : string {
376376
PluginFormcreatorSection::getForeignKeyField() => $sectionsList,
377377
];
378378
$html.= '<div class="div_show_condition_field">';
379-
$html.= PluginFormcreatorQuestion::dropdown(
379+
$html .= PluginFormcreatorQuestion::dropdownForForm(
380+
$form->getID(),
381+
$questionListExclusion,
382+
'_conditions[plugin_formcreator_questions_id][]',
383+
$questionId,
380384
[
381-
'name' => '_conditions[plugin_formcreator_questions_id][]',
382-
'value' => $questionId,
383-
'comments' => false,
384-
'condition' => $questionListExclusion,
385-
'rand' => $rand,
386-
'display' => false,
385+
'display' => false,
387386
]
388387
);
389388
$html.= '</div>';

inc/question.class.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,10 +1114,16 @@ public function getQuestionsFromFormBySection($formId, $crit = []) {
11141114
return $items;
11151115
}
11161116

1117-
public static function dropdownForForm($formId, $crit, $name, $value) {
1117+
public static function dropdownForForm($formId, $crit, $name, $value, $options = []) {
11181118
$question = new self();
11191119
$items = $question->getQuestionsFromFormBySection($formId, $crit);
1120-
Dropdown::showFromArray($name, $items, $value);
1120+
$options = [
1121+
'display' => $options['display'] ?? true,
1122+
'value' => $value,
1123+
];
1124+
$output = Dropdown::showFromArray($name, $items, $options);
1125+
1126+
return $output;
11211127
}
11221128

11231129
/**

0 commit comments

Comments
 (0)