This project is read-only.

Construction of html output, suggestions on where to look

Feb 14, 2012 at 3:41 PM

For my own purposes I've tweaked the HtmlFormHelper.cs to display the html which is output. I originally thought I messed something up because my checkbox lists would display the "required" symbol, however, the validation is not firing even though I put [Required] as a metadata attribute in the model. Any thoughts on whether or not I missed a file to include?

And just for future users, although the blog for Adding Rich Selector Support states three files you have to use, it's actually a few of the files contained in the Helpers folder as well. Off the top of my head:





Feb 20, 2012 at 3:03 PM

Yea that is a design choice I made in the HtmlFormHelper to check if the type is boolean, and if so not to display required field. For my purposes, I just thought it looked weird to have a required checkbox, since it is either checked or unchecked, it's never in an invalid state. Now if you want to require that it is indeed Checked == true, then that would be a different attribute altogether I believe.

[Required] validation does not ensure that a bool value == true, it just validates to make sure it isn't null, like a bool? property. You would need another validator to validate that the user actually checked it. I think the [RangeValidator] (surprisingly enough) actually does this out of the box.