configpanel: fix choices

This commit is contained in:
axolotle 2023-04-13 14:05:03 +02:00
parent c439c47d67
commit fe2761da4a

View file

@ -30,6 +30,8 @@ from moulinette.utils.log import getActionLogger
from yunohost.utils.error import YunohostError, YunohostValidationError from yunohost.utils.error import YunohostError, YunohostValidationError
from yunohost.utils.form import ( from yunohost.utils.form import (
OPTIONS, OPTIONS,
BaseChoicesOption,
BaseInputOption,
BaseOption, BaseOption,
FileOption, FileOption,
ask_questions_and_parse_answers, ask_questions_and_parse_answers,
@ -148,7 +150,9 @@ class ConfigPanel:
option["ask"] = ask option["ask"] = ask
question_class = OPTIONS[option.get("type", "string")] question_class = OPTIONS[option.get("type", "string")]
# FIXME : maybe other properties should be taken from the question, not just choices ?. # FIXME : maybe other properties should be taken from the question, not just choices ?.
if issubclass(question_class, BaseChoicesOption):
option["choices"] = question_class(option).choices option["choices"] = question_class(option).choices
if issubclass(question_class, BaseInputOption):
option["default"] = question_class(option).default option["default"] = question_class(option).default
option["pattern"] = question_class(option).pattern option["pattern"] = question_class(option).pattern
else: else: