Save Submit Admin Area

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 лет назад
Following the Nop commerce plugin tutorial on plural site ive hit an issue with the submit.

ive made tweaks to see if i could get it working but no luck.

heres my view code.

    
@using Nop.Web.Framework;
@using Nop.Core;
@using System.Linq;
@using Nop.Web.Framework.UI;
@using Nop.Web.Framework;
@model Nop.Plugin.Widgets.PromoSlider.Domain.PromoSliderRecord

@{ Layout = "_AdminLayout.cshtml"; }

<div class="content">
    <div class="form-horizontal">
        <div id="slider-edit" class="nav-tabs-custom">
            <ul class="nav nav-tabs">
                @Html.RenderBootstrapTabHeader("Slider", @T("Slider"), true)
                @Html.RenderBootstrapTabHeader("Images", @T("Images"))
            </ul>
            <div class="tab-content">
                @Html.RenderBootstrapTabContent("Slider", Sliders(), true)
                @Html.RenderBootstrapTabContent("Images", Images(), false)
            </div>
        </div>
    </div>
</div>
@helper Sliders()
{
using (Html.BeginForm())
{

        <div class="panel-group">
            <div class="panel panel-default">
                <div class="panel-body">
                    <div>
                        <div class="adminData">@Html.HiddenFor(m => m.PromoSliderId)</div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-2">@Html.NopLabelFor(m => m.PromoSliderName)</div>
                        <div class="col-md-9">
                            @Html.EditorFor(m => m.PromoSliderName)
                            @Html.ValidationMessageFor(m => m.PromoSliderName)
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-2">@Html.NopLabelFor(m => m.IsActive)</div>
                        <div class="col-md-9">
                            @Html.EditorFor(m => m.IsActive)
                            @Html.ValidationMessageFor(m => m.IsActive)
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-2">@Html.NopLabelFor(m => m.Interval)</div>
                        <div class="col-md-9">
                            @Html.EditorFor(m => m.Interval)
                            @Html.ValidationMessageFor(m => m.Interval)
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-2">@Html.NopLabelFor(m => m.Wrap)</div>
                        <div class="col-md-9">
                            @Html.EditorFor(m => m.Wrap)
                            @Html.ValidationMessageFor(m => m.Wrap)
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-2">@Html.NopLabelFor(m => m.PauseOnHover)</div>
                        <div class="col-md-9">
                            @Html.EditorFor(m => m.PauseOnHover)
                            @Html.ValidationMessageFor(m => m.PauseOnHover)
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-2">@Html.NopLabelFor(m => m.ZoneName)</div>
                        <div class="col-md-9">
                            @Html.DropDownListFor(m => m.ZoneName, new SelectList(
                        new List<string>() {
                            "producdivetails_top",
                            "categorydetails_after_breadcrumb",
                            "home_page_top"
                        }))
                            @Html.ValidationMessageFor(m => m.ZoneName)
                        </div>
                    </div>
                </div>
            </div>
        </div>                    
        <br />
        <div class="pull-right">
            <button type="submit" name="save" class="btn bg-blue">
                <i class="fa fa-floppy-o"></i>
                @T("Admin.Common.Save")
            </button>
        </div>
}

}

@helper Images()
{
    if (Model.PromoSliderId > 0)
    {
        @Html.Action("ManagePromoImages", new { PromoSliderId = Model.PromoSliderId })
    }
    else
    {
        <p>Please create and save a slider first.</p>
    }

}


heres the controller:

    
public ActionResult CreateUpdatePromoSlider(int PromoSliderId = 0)
        {
            PromoSliderRecord slider = new PromoSliderRecord() { Interval = 3 };
            if (PromoSliderId > 0)
            {
                slider = _sliderRepo.GetById(PromoSliderId);
            }
            return View(slider);
        }

        [HttpPost]
        public ActionResult CreateUpdatePromoSlider(PromoSliderRecord record)
        {
            if (ModelState.IsValid)
            {...


When i debug, i hit the get Action Result and can step through.
When i hit the save button on the view in the admin area nothing happens, nothing submits.

Anyone got an idea why submits are not working in my view?
7 лет назад
How about plugin class that implements IWidgetPlugin interface?
Inside the implementation of following method

void GetConfigurationRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues);
7 лет назад
Ive checked my plugin class route and seems fine, heres the code


using Nop.Core.Plugins;
using Nop.Plugin.Widgets.PromoSlider.Data;
using Nop.Services.Cms;
using Nop.Web.Framework.Menu;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Routing;

namespace Nop.Plugin.Widgets.PromoSlider
{
    public class PromoSliderPlugin : BasePlugin, IWidgetPlugin, IAdminMenuPlugin
    {
        private PromoSliderObjectContext _context;

        public PromoSliderPlugin(PromoSliderObjectContext context)
        {
            _context = context;
        }

        public void GetConfigurationRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues)
        {
            actionName = "Configure";
            controllerName = "PromoSlider";
            routeValues = new RouteValueDictionary()
            {
                { "Namespaces","Nop.Plugin.Widgets.PromoSlider.Controllers" },
                { "Area", null }
            };
        }

        public void GetDisplayWidgetRoute(string widgetZone, out string actionName, out string controllerName, out RouteValueDictionary routeValues)
        {
            actionName = "PromoSliderWidget";
            controllerName = "PromoSlider";
            routeValues = new RouteValueDictionary()
            {
                { "Namespaces","Nop.Plugin.Widgets.PromoSlider.Controllers" },
                { "Area", null },
                { "widgetZone", widgetZone }
            };
        }

        public IList<string> GetWidgetZones()
        {
            return new List<string>();
        }

        public override void Install()
        {
            _context.Install();
            base.Install();
        }

        public void ManageSiteMap(SiteMapNode rootNode)
        {
            var parentNode = new SiteMapNode()
            {
                Visible = true,
                Title = "Promo Slider",
                RouteValues = new RouteValueDictionary() { { "Area", "Admin" } }
            };
            parentNode.ChildNodes.Add(new SiteMapNode
            {
                Visible = true,
                Title = "New Slider",
                Url = "/PromoSlider/CreateUpdatePromoSlider",
                RouteValues = new RouteValueDictionary() { { "Area", "Admin" } }
            });
            parentNode.ChildNodes.Add(new SiteMapNode
            {
                Visible = true,
                Title = "Manage Sliders",
                Url = "/PromoSlider/ManagePromoSliders",
                RouteValues = new RouteValueDictionary() { { "Area", "Admin" } }
            });

            rootNode.ChildNodes.Add(parentNode);
        }

        public override void Uninstall()
        {
            _context.UnInstall();
            base.Uninstall();
        }
    }

}


just doesnt do anything when i hit save
7 лет назад
How about "Configure" action in your "PromoSlider" controller?
7 лет назад
heres the source:

https://drive.google.com/a/mereway.co.uk/file/d/0Bwz6wIGYudUSdFdmeTFKRGRzajA/view?usp=sharing

as you can see the plugin is following the plural site tutorial that is suggested by the nop commerce documentation.

Although the tutorial is out of date as of 3.8 I have made some alterations to get it working.

However the submit just wont work. break point isnt even hit.  Looking at roityes they seem fine.
7 лет назад
[email protected] wrote:
heres the source:

https://drive.google.com/a/mereway.co.uk/file/d/0Bwz6wIGYudUSdFdmeTFKRGRzajA/view?usp=sharing

as you can see the plugin is following the plural site tutorial that is suggested by the nop commerce documentation.

Although the tutorial is out of date as of 3.8 I have made some alterations to get it working.

However the submit just wont work. break point isnt even hit.  Looking at roityes they seem fine.


Hi,

You should change as following in PromoSliderPlugin class

BEFORE

public void GetConfigurationRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues)
        {
            actionName = "Configure";
            controllerName = "PromoSlider";
            routeValues = new RouteValueDictionary()
            {
                { "Namespaces","Nop.Plugin.Widgets.PromoSlider.Controllers" },
                { "Area", null }
            };
        }


AFTER

public void GetConfigurationRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues)
        {
            actionName = "CreateUpdatePromoSlider";
            controllerName = "PromoSlider";
            routeValues = new RouteValueDictionary()
            {
                { "Namespaces","Nop.Plugin.Widgets.PromoSlider.Controllers" },
                { "Area", null }
            };
        }
7 лет назад
Yes i can see what you did there, however ive done as you suggested, cleaned and rebuilt, debugged and still no change, nothing happens and the POST is never hit.  Did you get it working your end?
7 лет назад
UPDATE:

I made a seperate begin.form outside the tabs, i added just the submit button, i then debugged and hit it. and bang it actually hit my controller!

So the major question is....why the hell wont this work inside a @helper?
7 лет назад
looks like the Begin form creates the form then closes it before it puts in the rest of the @helper code!!

Is this a bug??
7 лет назад
looks like the Begin form creates the form then closes it before it puts in the rest of the @helper code!!

Is this a bug??
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.