public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) {
            if (builder.FieldType != "BooleanField") {
                yield break;
            }

            var model = new BooleanFieldSettings();
            if (updateModel.TryUpdateModel(model, "BooleanFieldSettings", null, null)) {
                builder.WithSetting("BooleanFieldSettings.Hint", model.Hint);
                builder.WithSetting("BooleanFieldSettings.Optional", model.Optional.ToString(CultureInfo.InvariantCulture));
                builder.WithSetting("BooleanFieldSettings.NotSetLabel", model.NotSetLabel);
                builder.WithSetting("BooleanFieldSettings.OnLabel", model.OnLabel);
                builder.WithSetting("BooleanFieldSettings.OffLabel", model.OffLabel);
                builder.WithSetting("BooleanFieldSettings.SelectionMode", model.SelectionMode.ToString());
                builder.WithSetting("BooleanFieldSettings.DefaultValue", model.DefaultValue.HasValue ? model.DefaultValue.Value.ToString(CultureInfo.InvariantCulture) : string.Empty );
            }

            yield return DefinitionTemplate(model);
        }
Пример #2
0
        public override IEnumerable <TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (builder.FieldType != "BooleanField")
            {
                yield break;
            }

            var model = new BooleanFieldSettings();

            if (updateModel.TryUpdateModel(model, "BooleanFieldSettings", null, null))
            {
                builder.WithSetting("BooleanFieldSettings.Hint", model.Hint);
                builder.WithSetting("BooleanFieldSettings.Optional", model.Optional.ToString(CultureInfo.InvariantCulture));
                builder.WithSetting("BooleanFieldSettings.NotSetLabel", model.NotSetLabel);
                builder.WithSetting("BooleanFieldSettings.OnLabel", model.OnLabel);
                builder.WithSetting("BooleanFieldSettings.OffLabel", model.OffLabel);
                builder.WithSetting("BooleanFieldSettings.SelectionMode", model.SelectionMode.ToString());
                builder.WithSetting("BooleanFieldSettings.DefaultValue", model.DefaultValue.HasValue ? model.DefaultValue.Value.ToString(CultureInfo.InvariantCulture) : string.Empty);
            }

            yield return(DefinitionTemplate(model));
        }