protected override DriverResult Editor(ContentPart part, MediaGalleryField field, IUpdateModel updater, dynamic shapeHelper)
        {
            var model = new MediaGalleryFieldViewModel();

            updater.TryUpdateModel(model, GetPrefix(field, part), null, null);

            var settings = field.PartFieldDefinition.Settings.GetModel <MediaGalleryFieldSettings>();

            if (String.IsNullOrEmpty(model.SelectedItems))
            {
                field.SelectedItems = "[]";
            }
            else
            {
                field.SelectedItems = model.SelectedItems;
            }

            var allItems = _jsonConverter.Deserialize <MediaGalleryItem[]>(field.SelectedItems);

            if (settings.Required && allItems.Length == 0)
            {
                updater.AddModelError("SelectedItems", T("The field {0} is mandatory", field.Name.CamelFriendly()));
            }

            if (!settings.Multiple && allItems.Length > 1)
            {
                updater.AddModelError("SelectedItems", T("The field {0} doesn't accept multiple media items", field.Name.CamelFriendly()));
            }

            return(Editor(part, field, shapeHelper));
        }
        protected override DriverResult Editor(ContentPart part, MediaGalleryField field, dynamic shapeHelper)
        {
            return(ContentShape("Fields_MediaGallery_Edit", GetDifferentiator(field, part),
                                () => {
                var model = new MediaGalleryFieldViewModel {
                    Field = field,
                    Items = field.Items,
                    SelectedItems = field.SelectedItems
                };

                model.SelectedItems = string.Concat(",", field.Items);

                return shapeHelper.EditorTemplate(TemplateName: "Fields/MediaGallery.Edit", Model: model, Prefix: GetPrefix(field, part));
            }));
        }