mcintyre321 / FormFactory

MVC5, Core or standalone - Generate rich HTML5 forms from your ViewModels, or build them programatically
http://formfactoryaspmvc.azurewebsites.net/
MIT License
304 stars 102 forks source link

Disable edit for 1 or all property #33

Closed scinfu closed 5 years ago

scinfu commented 7 years ago

Hi, How can i disable edit for 1 or all property? The goal is to let user see the property but not edit it , like for property in readonly . Thank you

mcintyre321 commented 7 years ago

[Description("Readonly properties are rendered as readonly")] public int DaysSinceStartOfYear { get { return DateTime.Today.DayOfYear; } }

or you can do it in the view (or controller):

@{
var properties = FF.PropertiesFor(someObject);
properties.Single(p =>p.Name == "someProperty").ReadOnly = true;
@properties.Render();
}