Always bind to form object

asked 2015-02-18 10:08:22 +0800

JustinFrost gravatar image JustinFrost
143 1 6

I need to bind to my form even when validationMessages are added in Validators. This is because I am using the forms dirty status to show/hide the submit button on the form, so any change needs to cause these buttons to display.

Given my form is like this:

<div form="@id('formData') @load(vm.customerDetail) @save(vm.customerDetail, before='doSave')">

and my fields are like this:

<textbox id="customerName" value="@bind(formData.name) @validator(vm.fieldValidator)" inlineErrors="@bind(vmsgs.texts[customerName])"/>

How can I force name to be bound back to the form even if it fails validation and created ValidationMessages ?


delete flag offensive retag edit


stupid question maybe, but why do you use a validator and not constraint?

chillworld ( 2015-02-18 11:31:51 +0800 )edit

Hi Chillworld, the validator reads the validations required for that field from xml and then runs each validation and set validationMessages

JustinFrost ( 2015-02-18 11:36:58 +0800 )edit

and if you throw in the setter a WrongValueExeption, it creates the effect as constraint.(and you can give the WrongValueException the message to be shown)

chillworld ( 2015-02-18 12:15:58 +0800 )edit

otherwise a small working fiddle could help me to try something out

chillworld ( 2015-02-18 13:10:27 +0800 )edit

Do constraints prevent binding if they throw a WrongValueException ?

JustinFrost ( 2015-02-19 13:06:56 +0800 )edit
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2015-02-18 10:08:22 +0800

Seen: 11 times

Last updated: Feb 18 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More