Skip to content

Saving "TextField" data from a "Keyboard Event" (with "errors filters") is ignored #3940

Closed Answered by tanmay-bhatgare
nastiliano asked this question in Q&A
Discussion options

You must be logged in to vote

I think you problem is solved but want you to review it. I added two extra functions, validate_textfield and other_events one to validate textfield input and another one so when TextField changes or loses focus.

import flet as ft


def main(page: ft.Page):
    appbar_text_ref = ft.Ref[ft.Text]()

    def validate_textfield():
        if len(textfield.value) <= 1:
            textfield.error_text = "Field must have more than 1 character."
            page.update()
            return False
        textfield.error_text = ""
        page.update()
        return True

    def handle_menu_item_click(e):
        print(f"{e.control.content.value}.on_click")
        page.open(
            ft.SnackBar

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@nastiliano
Comment options

@tanmay-bhatgare
Comment options

Answer selected by ndonkoHenri
@nastiliano
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants