Skip to content

Boolean value in update form is always required #277

Open
@ManiMozaffar

Description

@ManiMozaffar
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions