Skip to content

Commit

Permalink
fix(condition): loss of condition on submit button
Browse files Browse the repository at this point in the history
also improve questions dropdown to edit conditions

Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Jan 20, 2021
1 parent 92629fe commit 42d5fed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
13 changes: 6 additions & 7 deletions inc/condition.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,13 @@ public function getConditionHtml(array $input) : string {
PluginFormcreatorSection::getForeignKeyField() => $sectionsList,
];
$html.= '<div class="div_show_condition_field">';
$html.= PluginFormcreatorQuestion::dropdown(
$html .= PluginFormcreatorQuestion::dropdownForForm(
$form->getID(),
$questionListExclusion,
'_conditions[plugin_formcreator_questions_id][]',
$questionId,
[
'name' => '_conditions[plugin_formcreator_questions_id][]',
'value' => $questionId,
'comments' => false,
'condition' => $questionListExclusion,
'rand' => $rand,
'display' => false,
'display' => false,
]
);
$html.= '</div>';
Expand Down
10 changes: 8 additions & 2 deletions inc/question.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1114,10 +1114,16 @@ public function getQuestionsFromFormBySection($formId, $crit = []) {
return $items;
}

public static function dropdownForForm($formId, $crit, $name, $value) {
public static function dropdownForForm($formId, $crit, $name, $value, $options = []) {
$question = new self();
$items = $question->getQuestionsFromFormBySection($formId, $crit);
Dropdown::showFromArray($name, $items, $value);
$options = [
'display' => $options['display'] ?? true,
'value' => $value,
];
$output = Dropdown::showFromArray($name, $items, $options);

return $output;
}

/**
Expand Down

0 comments on commit 42d5fed

Please sign in to comment.