This project is read-only.

Multiple instance of the same field type

Topics: Customizing Orchard
Oct 3, 2012 at 10:58 AM


I'm trying to develop a Location field (basically an Address model with AddressLine1, AddressLine2, City, Country etc properties). The business requirement is that for a given Content Type say "Company", it has multiple office locations in various countries/cities.

The other requirement is that the Location field, has a Country property which can only be selected from a fixed list.

How would I go about implementing for the above? Currently Orchard doesn't seem it can support multiple custom fields

Oct 3, 2012 at 11:23 AM

It does: plenty of our custom fields are used 2+ times on certain content types.

Oct 3, 2012 at 1:00 PM

What we need is the number of field instances not be fixed. ie Acme Inc could potentially add 100 locations, but your Local Deli would only have 1 location.

For example, the EnumerationField class to take in a generic object, rather than the string it is using.

Oct 3, 2012 at 1:57 PM

Well then you'll have to create a field that can do just that.

We for example have a 'MultiBody' field that can have n content 'bodies' (that we render out as tabbed content)

We store the entries as json inside the field.

Oct 3, 2012 at 3:22 PM

Ok, sounds like we need to write an EnumerationContainerField, or something to that effect.

Oct 4, 2012 at 4:46 PM

A better way would be to enhance the content picker (or make another field if it is to different) :

- Allow it to specify a Projection query and a Property (tokenized) to display.

- Allow to use a dropdownlist for a single selection or a Checkboxlist (or an autocomplete textbox) for multiple selection.


Some feature like this as already been asked and postponed for a later version :

Vote for it if you want it, or better : develop it.

Oct 4, 2012 at 4:50 PM

It would also be interesting to have some recipes to help importing data like countries, States, postal codes, ...

That kinds of references (data that don't change often) would be helpful for most people.