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

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

Open
PHvL opened this issue Jun 27, 2024 · 0 comments
Open

Comments

@PHvL
Copy link

PHvL commented Jun 27, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant