disable/enable/hide form elements dependent on input in another element · Issue #337 · pydantic/FastUI · GitHub
Skip to content
This repository was archived by the owner on Jun 7, 2026. It is now read-only.
This repository was archived by the owner on Jun 7, 2026. It is now read-only.

disable/enable/hide form elements dependent on input in another element #337

Open

Description

@PHvL

Hi,
Thanks for this great tool.

We often have forms where some questions do not make sense if a question was answered in a specific way before. For example, on a feedback form to an invitation, we ask if the invitee will attend the event (a required bool field), and if they attend, we ask how many guests they will bring with them (an optional int field):

from typing import Annotated, Optional
from pydantic import BaseModel, Field
from fastui import components as c

class Feedback(BaseModel):
	attendance: Annotated[bool, Field(title='I will attend the ceremony.')]
	attendees_count: Annotated[Optional[int], Field(title='I will be accompanied by (max 5) additional guest(s).')] = None

c.ModelForm(submit_url='./answer', model=Feedback)

Is it possible to disable/enable or maybe even hide/unhide form element attendees_count depending on the value of attendance?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions