-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Hello! I have encountered an issue with using the default_value parameter in the questions package. When using this parameter for DropdownQuestion type questions, it does not apply and the default selected value is not displayed.
Here's a minimal code example that demonstrates this issue:
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from questions import DropdownQuestion, Form, FormPage
import uvicorn
class Page(Form):
person = DropdownQuestion(
title="Full name",
choices=["George Corbyn", "Stanley Castillo", "Ida Stanley"],
default_value="Stanley Castillo",
)
class Profile(Form):
page = FormPage(Page, title="Author")
def form():
html = Profile().render_html()
return HTMLResponse(html)
if __name__ == "__main__":
app = FastAPI()
app.get("/")(form)
uvicorn.run(app, host="0.0.0.0", port=8888)In this example, the default_value has no effect, and the default selected value "Stanley Castillo" is not set in the dropdown list.
I have also tested this issue with other question types that inherit from ChoicesQuestion, and they also do not apply the default_value.
I expected that when using the default_value parameter in the DropdownQuestion definition, the default selected value would be displayed in the input field.
Env:
questions package version: 0.8.0
Python version: 3.11
Operating system: Linux