Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean value in update form is always required #277

Open
ManiMozaffar opened this issue Apr 19, 2024 · 1 comment
Open

Boolean value in update form is always required #277

ManiMozaffar opened this issue Apr 19, 2024 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@ManiMozaffar
Copy link
Contributor

ManiMozaffar commented Apr 19, 2024

class UpdateForm(BaseModel):
    is_foo: bool

Renders to a required checkbox, so it always has to be "true" on submission!
Screenshot 2024-04-19 at 11 18 30

workaround for now is to consider None as False. (so it makes checkbox optional), but that'd be cool to see this fixed :)

BoolUpdate = Annotated[bool | None, AfterValidator(lambda v: False if v is None else v)]
class UpdateForm(BaseModel): 
    is_foo: BoolUpdate = False
@ManiMozaffar ManiMozaffar changed the title Boolean value in form is always required Boolean value in filter form is always required Apr 19, 2024
@ManiMozaffar ManiMozaffar changed the title Boolean value in filter form is always required Boolean value in update form is always required Apr 19, 2024
@sydney-runkle sydney-runkle added this to the v2.6.0 milestone Apr 19, 2024
@sydney-runkle sydney-runkle added the bug Something isn't working label May 2, 2024
@sydney-runkle
Copy link
Member

@ManiMozaffar,

Thanks for the report. Looks like a bug indeed!

@sydney-runkle sydney-runkle modified the milestones: v0.6.0, v0.7.0 May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants