-
Notifications
You must be signed in to change notification settings - Fork 95
Description
Hi!
I am trying to create a form programmatically as the form fields are being saved in a database so the users can create their own forms with their own data. This part I have working and the forms are displayed exactly as they should.
The only issue is that when the "NotOptional" value is set to true, there is no validation done on the form when it is submitted.
Below is an example using the demo "Programmatically created form" data and when it is submitted, it submits and does not show that the fields are required or cancel the submission like it does on the first demo called "Auto Complete" here: http://formfactory.apphb.com/
Any idea why this is happening and not validating?
<form action="/home/save" method="POST"> @{ var formModel = new[] { new PropertyVm(typeof(string), "username") { DisplayName = "Username", NotOptional = true, }, new PropertyVm(typeof(string), "password") { DisplayName = "Password", NotOptional = true, GetCustomAttributes = () => new object[] {new PasswordAttribute()} }, new PropertyVm(typeof(string), "os") { DisplayName = "Operating System", NotOptional = true, Choices = new List<string>() {"OSX", "IOS", "Windows", "Android"}, Value = "Windows", //Preselect windows GetCustomAttributes = () => new object[] {new RadioAttribute()}, }, new PropertyVm(typeof(string) , "textmessage") { DisplayName = "Type a message:", NotOptional =false, GetCustomAttributes = () => new object[] { new MultilineTextAttribute(), new DisplayAttribute(){Prompt = "placeholder??"}, new SuggestionsUrlAttribute( "/home/CountrySuggestions" ) }, }, }; @formModel.Render( Html ) } <input type="submit" value="submit" /> </form>