I am working on an ASP.NET MVC based CMS that presents a rather extreme case. The system must allow the user to add custom content types based on different fields, and for every field, one can add options and validations. The thing is that everything is stored in a complex DB and extracted at runtime using LINQ.
I am pretty fresh with ASP>NET MVC so the following dilemma came to mind How should I make the content creation view so that form helpers are not predefined int he view code but are loaded based on the type of the field ? Do I have to create a factory class that checks the value of the type property of the field, and then returns a helper based on that or there's a better way to do it. This one seems pretty rigid to me , because anytime I make a change in the Fieldtypes table, I will have to make sure to create a check for that new type too.
public class CType {
string Name; //e.g Post Article etc
List<ContentData> data ;
...
}
public class ContentData {
string Data; // Basically this is the data stored for each field
FieldInstance fieldInstance;
...
}
public class FieldInstance {
string Title; // e.g Title Body etc.
FieldType Type ; // e.g textbox textarea image checkbox etc
...
}
public class FieldType {
string Type; // e.g textbox textarea image checkbox etc
...
}