Search code examples
orchardcmsorchardcms-1.8

Orchard CMS 1.8.1 - Migrations WithSetting not saving


I have followed all the examples I founded and none works.

My code (in the Migrations.cs)

.WithField("PeopleText", f => f
    .OfType("TextField")
    .WithDisplayName("People / Team"))

    //TODO: Not sure why these settings not taking effect!
    .WithSetting("TextFieldSettings.Flavor", "Html") 
    .WithSetting("TextFieldSettings.Required", "true")

None of the above 2 settings saved

enter image description here

I'm not sure it's known bug of version 1.8.1 or I have done something terrible wrong?

Cheers,

Hugh


Solution

  • You are closing your field migration to soon, which causes the .WithSetting to chain to the part instead of the field:

    .WithField("PeopleText", f => f
        .OfType("TextField")
        .WithDisplayName("People / Team")) // <-- here you close your field chain, so everything after this will attach to the part chain
    

    If you change it to the following it will work:

    .WithField("PeopleText", f => f
        .OfType("TextField")
        .WithDisplayName("People / Team")
    
        .WithSetting("TextFieldSettings.Flavor", "Html") 
        .WithSetting("TextFieldSettings.Required", "true")) // Close field chain here