Create Form

Mar 3, 2011 at 6:47 PM
Edited Mar 3, 2011 at 7:06 PM

Hi,

I am using the person template and trying to add the following

[DisplayName("Is Approved")]

public bool IsApproved { get; set; }

property in the PersonCreateInput.cs. But it does seem to render correctly in the create form. It only shows the checkbox. The display property is not shown.

I am using the MVC 2.0 version.

I checked with your latest version MVC3. It renders correctly there. But i dont want to use razor.

Could you suggest how to rectify this.

Mar 3, 2011 at 7:22 PM
Edited Mar 3, 2011 at 7:23 PM

hi,

I kinda debugged it and it seems that the AwesomeModelMetadataProvider is throwing up an exception.

It says base {System.SystemException} = {"Method may only be called on a Type for which Type.IsGenericParameter is true."}

Does that mean we can render checkboxes ?

PS: I did not find you use checkboxes/radio buttons in any of your examples.

Mar 4, 2011 at 7:31 AM

check if there is a Boolean.aspx in EditorTemplates

Mar 4, 2011 at 8:08 AM
Edited Mar 4, 2011 at 8:33 AM

HI,

It was not there. I placed the Boolean.aspx in the EditorTemplates. It is now showing up properly. I am using your 5375 base. 

But i wonder why is it marking the checkbox as required in the createform even though i am not marking it mandatory ??

 

Thanks

Mar 4, 2011 at 9:00 AM

Hi,

Debugging shows that the isRequired property in ModelMetaData for this property set to true. Am i missing any other files ?

Thanks

Mar 4, 2011 at 9:19 AM
Edited Mar 4, 2011 at 9:19 AM

any non nullable is required by default (int, bool, DateTime, ...)

use bool?

also, you can use mvc 3 with aspx (web forms view engine)

Mar 4, 2011 at 10:29 AM
Edited Mar 4, 2011 at 11:40 AM

Hi,

So how do i create a checkbox using the framework which will not be mandatory ? and i used bool . and this works with a normal MVC application.

Mar 4, 2011 at 11:39 AM

Html.Checkbox("isIt")

Html.CheckboxFor(o => o.IsIt) //having public bool? IsIt {get;set;}

Html.EditorFor(o => o.IsIt) // having the above and editor template for bool