OrchardCMS / Orchard

Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
https://orchardproject.net
BSD 3-Clause "New" or "Revised" License
2.38k stars 1.12k forks source link

Creating a MenuItem With fields attached wont save those fields first time #3901

Open orchardbot opened 11 years ago

orchardbot commented 11 years ago

@jetski5822 created: https://orchard.codeplex.com/workitem/20073

Create a new Menu Item... i.e.

Then go and add that menu item to your navigation menu populating the fields. Hit Save, return to that menu item and you will see those fields are not populated. Add the details again to the fields and save and all works as expected.

orchardbot commented 9 years ago

joshby commented:

Submitted a pull request to fix.

https://orchard.codeplex.com/SourceControl/network/forks/joshby/orchard/contribution/7813

orchardbot commented 9 years ago

@sebastienros commented:

Can you still repro it on 1.x ?

orchardbot commented 9 years ago

tadeutorres commented:

It's stil happening in 1.x. Just tested it.

MediaLinkPartRecord just don't save in first try in a menuitem. Second time it saves normally.

dmitrymatviets commented 9 years ago

I made a fix, seems to be working

   [HttpPost, ActionName("CreateMenuItem")]
        public ActionResult CreateMenuItemPost(string id, int menuId, string returnUrl) {
            if (!Services.Authorizer.Authorize(Permissions.ManageMainMenu, T("Couldn't manage the main menu")))
                return new HttpUnauthorizedResult();

            var menuItem = Services.ContentManager.New(id);

            if (menuItem == null)
                return HttpNotFound();

            // load the menu
            var menu = Services.ContentManager.Get(menuId);

            if (menu == null)
                return HttpNotFound();

            Services.ContentManager.Create(menuItem);

            var model = Services.ContentManager.UpdateEditor(menuItem, this);

            var menuPart = menuItem.As<MenuPart>();
            menuPart.MenuPosition = Position.GetNext(_navigationManager.BuildMenu(menu));
            menuPart.Menu = menu;

            if (!ModelState.IsValid) {
                Services.TransactionManager.Cancel();
                return View(model);
            }

            Services.Notifier.Information(T("Your {0} has been added.", menuItem.TypeDefinition.DisplayName));

            return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));
        }