Add Field(s) to ContentPart?

Topics: Writing modules
Feb 22, 2011 at 3:50 PM

I am trying to add a field to a ContentPart when the Feature is enabled.  In my migration file I have this:

ContentDefinitionManager.AlterPartDefinition(
                typeof(BeltPart).Name, cfg => cfg
                    .WithField(typeof(ImageField).Name)
                    .WithSetting("MaxWidth", "250")
                    .WithSetting("MaxHeight", "250")
                    .WithSetting("ResizeAction", "Resize")
                    .Named("Image"));
Am I missing something?

Feb 22, 2011 at 4:12 PM

I found the answer:

 

ContentDefinitionManager.AlterPartDefinition(
                typeof(BeltPart).Name, cfg => cfg
                    .WithField(typeof(ImageField).Name, t => t
                    .WithSetting("MaxWidth", "250")
                    .WithSetting("MaxHeight", "250")
                    .WithSetting("ResizeAction", "Resize")
                    .OfType(typeof(ImageField).Name)
                    .WithSetting("FileName", "Image")
                    ));