Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-1651

Apply form validator to only specific submit button commands?

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • None
    • Databind
    • None

      Sorry if this feature is already available, but I'm not seeing it (I'm thinking there is a way around this issue, since I'm sure it has come up.) Currently, it seems like if you apply a form validator to a form, it will apply to all 'save' methods defined for your form. Typically this is what you would want, but sometimes you might have another button on your form that you want executed on your view model and you'd like to get the user inputted information but you do not want the form validation to fire. If you're using form binding this seems to be problematic. I noticed this issue when trying to help someone with this post here http://forum.zkoss.org/question/85466/search-button-using-validation/?answer=85521#post-id-85521

      The user above wanted to also put a "search button" on their form but didn't want all the validations to process when clicking search. Taking a ZK example that exists, how would one modify this ZK sample http://www.zkoss.org/zkdemo/input/form_sample so that next to the username field they might have a button that runs a "checkIfExists" command on the ViewModel? In your viewModel you'd need a handle to the username field but it wouldn't be populated unless it was defined in the @save declaration, but if you defined as a command in the @save declaration, then your form validator would also fire?

      I was thinking maybe provide a way to explicitly define the commands you want to have validated:

      @validator(vm.myValidator, applyTo=

      {'save','update'}

      ) //would ignore 'search' for instance

            Unassigned Unassigned
            rickcr rickcr
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: