We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I'm trying to implement a Search form. I want to also have a Clear button that will reset the text input field of the form:
Search
Clear
Here is the form model, which has a single query string field:
query
Form Model Definition
class SearchForm(BaseModel): query: Optional[str] = Field(None, title=' ', description='Use keywords to search')
For form is a ModelForm component:
ModelForm
Form Component in Page
c.ModelForm(model=SearchForm, display_mode='default', submit_url='/api/search/', method='POST', initial={'query': q}, class_name='+ mb-2')
The search endpoint sets the q variable in my page:
q
Form's POST Endpoint
@router.post('/api/search/', response_model=FastUI, response_model_exclude_none=True) async def big_form_post(form: Annotated[SearchForm, fastui_form(SearchForm)]): return [c.FireEvent(event=GoToEvent(url='/search/', query={'q': form.query}))]
I tried to create a button that clears the search box with an on_click event that invokes GoToEvent(url='/search/', query={'q': ""}):
GoToEvent(url='/search/', query={'q': ""})
Clear Search Button
c.Button(text='Clear Search', on_click=GoToEvent(url='/search/', query={'q': ""}))
When I click the button, I can see that the request gets processed and theq variable is correctly set to an empty string.
However, the form field doesn't get reset to an empty string.
Any ideas what I could try? Might this be a bug?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I'm trying to implement a
Search
form. I want to also have aClear
button that will reset the text input field of the form:Here is the form model, which has a single
query
string field:Form Model Definition
For form is a
ModelForm
component:Form Component in Page
The search endpoint sets the
q
variable in my page:Form's POST Endpoint
I tried to create a button that clears the search box with an on_click event that invokes
GoToEvent(url='/search/', query={'q': ""})
:Clear Search Button
When I click the button, I can see that the request gets processed and the
q
variable is correctly set to an empty string.However, the form field doesn't get reset to an empty string.
Any ideas what I could try? Might this be a bug?
The text was updated successfully, but these errors were encountered: