コード例 #1
0
        public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) {
            if (builder.FieldType != "TaxonomyField") {
                yield break;
            }

            var model = new TaxonomyFieldSettings();

            if (updateModel.TryUpdateModel(model, "TaxonomyFieldSettings", null, null)) {
                builder
                    .WithSetting("TaxonomyFieldSettings.Taxonomy", model.Taxonomy)
                    .WithSetting("TaxonomyFieldSettings.LeavesOnly", model.LeavesOnly.ToString())
                    .WithSetting("TaxonomyFieldSettings.Required", model.Required.ToString())
                    .WithSetting("TaxonomyFieldSettings.SingleChoice", model.SingleChoice.ToString())
                    .WithSetting("TaxonomyFieldSettings.Autocomplete", model.Autocomplete.ToString())
                    .WithSetting("TaxonomyFieldSettings.AllowCustomTerms", model.AllowCustomTerms.ToString())
                    .WithSetting("TaxonomyFieldSettings.Hint", model.Hint);
            }

            yield return DefinitionTemplate(model);
        }
コード例 #2
0
        public override IEnumerable <TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (builder.FieldType != "TaxonomyField")
            {
                yield break;
            }

            var model = new TaxonomyFieldSettings();

            if (updateModel.TryUpdateModel(model, "TaxonomyFieldSettings", null, null))
            {
                builder
                .WithSetting("TaxonomyFieldSettings.Taxonomy", model.Taxonomy)
                .WithSetting("TaxonomyFieldSettings.LeavesOnly", model.LeavesOnly.ToString())
                .WithSetting("TaxonomyFieldSettings.Required", model.Required.ToString())
                .WithSetting("TaxonomyFieldSettings.SingleChoice", model.SingleChoice.ToString())
                .WithSetting("TaxonomyFieldSettings.Autocomplete", model.Autocomplete.ToString())
                .WithSetting("TaxonomyFieldSettings.AllowCustomTerms", model.AllowCustomTerms.ToString())
                .WithSetting("TaxonomyFieldSettings.Hint", model.Hint);
            }

            yield return(DefinitionTemplate(model));
        }