ContentTypes -> Fields -> DataAnnotations

Dec 21, 2010 at 11:56 AM

I understand that business rules will be hard, even harder doing it client side with server Json calls where a field has dependency's on other field values.
But the simple rules, like if a field is required or must be within a lenght rule.. will they come in the near future ?

Dec 21, 2010 at 6:13 PM

If you mean fields created in the admin UI - DataAnnotations attributes (and attributes at all) must depend on values available at compile-time, not run-time so they cannot be applied in such a dynamic scenario. It would have to be done in some other way, but is surely doable. Currently, if you want to have a more complex business logic behind fields/types, you have to write your own fields/parts, and then use them in the UI type creation.

Cheers, Piotr

Dec 21, 2010 at 6:28 PM

Ok DataAnnotations are a special thing, but i ment business rules. Server side validation on postback should be enough, however client validation might be required in special cases.
Maybe a custom field with validation attached can be used.. i'll look into it.

The Admin UI for "dynamic" content is not sufficient at all, for now just for simple things :)

Dec 21, 2010 at 6:40 PM

Yes, actually fields can have settings, so you could imagine a numeric field that has settings for the allowed range for example... Even without settings, an email field for example could do validation from its edit template and driver.

Dec 21, 2010 at 6:54 PM

The PartRecord class is for NHibernate to do it's work right? How about the Part class, it must be exist to let it be an ContentType?
I was thinking about putting a CSLA BusinessObject ( between the PartRecord (or the Part) and the ViewModel (or use it as a ViewModel)
CSLA has good functionality for business rules.


Dec 21, 2010 at 6:59 PM

Sure but we're not talking about content fields, then, but about part properties. Yes, you can party on that all you want. The part is exactly the right place to do that. For an example of validation, you can take a look at the RoutePartDriver in Orchard.Core.

Dec 21, 2010 at 7:08 PM

Indeed, using content fields is probl. not what we are going to do.
Generating modules with some tt4 is still the idea i've in mind..

The only problem is that i'm kinda new to ASP.NET MVC and i guess i know more about Orchard then MVC lol

I'm yet a WPF / Silverlight kind of guy, but there is a requirement to make it 100% cross-platform.
And i want to forget about servercontrols, taking a risk to believe mvc is the future :)

I'll learn until next year...