Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Openfield Creative 62 posts 222 karma points
    Feb 22, 2016 @ 20:37
    Openfield Creative
    0

    Form Submit not working with Route Hijacking

    I'm having issues with getting a form to submit while using route hijacking. I've gotten the form to render but nothing happens when I click Submit. I've read through the documentation and tried several different set ups but nothing seems to work.

    I've tried having it setup within a controller inheriting from RenderMvcControl and with a controller inheriting from SurfaceController and using a Surface controller called from a partial view and all give me the same result.

    Here is my code as it is now

    Model

    public class SubmitIssueModel : RenderModel
    {
    
        public SubmitIssueModel() : this(new UmbracoHelper(UmbracoContext.Current).TypedContent(UmbracoContext.Current.PageId)) { }
        public SubmitIssueModel(IPublishedContent content) : base(content) { }
    
        public string Company_id { get; set; }
        public decimal CaseId { get; set; }
        public decimal Issue { get; set; }
        public string Department { get; set; }
        public string IssueStatus { get; set; }
        public DateTime IssueOpen { get; set; }
        public string IssueState { get; set; }
    
        [Required]
        [DisplayName("Summary")]
        public string Description { get; set; }
    
        [Required]
        [DisplayName("Description")]
        public string CaseText { get; set; }
        public string Priority { get; set; }
        public string Openby { get; set; }
        public DateTime Closedate { get; set; }
        public string Version { get; set; }
        public string Impact { get; set; }
        public string Agent { get; set; }
        public string Product { get; set; }
    
    }
    

    View (SubmitIssues.cshtml)

    <p>Temp @TempData["Success"]</p>
    
        @using (Html.BeginForm("SubmitForm", "CreateIssueSurface"))
        {
           @Html.LabelFor(Model => Model.Description)
            @Html.TextBoxFor(Model => Model.Description)
    
            @Html.LabelFor(Model => Model.CaseText)
            @Html.TextAreaFor(Model => Model.CaseText)
    
            <label>Product*</label>
            @Html.DropDownListFor(Model => Model.Product, productList, "Select")
    
            <br />
    
            @Html.LabelFor(Model => Model.Version)
            @Html.TextBoxFor(Model => Model.Version)
    
    
            <h5>Customer Priority</h5>
            @Html.DropDownListFor(Model => Model.Priority, priorityList)
    
            <!--<h5>Attachment</h5>
    <input name="attachment" type="file" />-->
    
            <br /><br /><br />
    
            <input type="button" class="button" value="Submit" />
    
    
    
        }
    

    Controller

     public class SubmitIssuesController : RenderMvcController
    {
      public ActionResult SubmitIssues() {
    
           return View(new SubmitIssueModel());
        }
    
    }
    
    public class CreateIssueSurfaceController : SurfaceController { 
        [HttpPost]
        public ActionResult SubmitForm(SubmitIssueModel model){
    
            TempData.Add("Success", "This is a test");
            return RedirectToCurrentUmbracoPage();
    
        }
    }
    

    Any help would really be appreciated.

    Thanks,

    Owen

  • James 251 posts 1169 karma points
    Feb 22, 2016 @ 21:38
    James
    0

    Hello,

    Just a thought but have you tried beginumbracoform?

    @model CommentViewModel

    @using(Html.BeginUmbracoForm("CreateComment", "BlogPostSurface")) { }

  • Openfield Creative 62 posts 222 karma points
    Feb 22, 2016 @ 22:12
    Openfield Creative
    0

    Thanks for the response James.

    I have tried BeginUmbracoForm and it gets me the same result, which is no result.

    Just to add a little more information, I just noticed that the code above generates the following as the beginning form tag:

    <form action="/issues/submit-an-issue/" enctype="multipart/form-data" method="post">
    
  • James 251 posts 1169 karma points
    Feb 22, 2016 @ 23:27
    James
    0

    Does the page submit and redirect but with no update to temp data ?

  • Openfield Creative 62 posts 222 karma points
    Feb 22, 2016 @ 23:57
    Openfield Creative
    0

    It's not submitting at all. I can't get anything to happen when clicking submit. I tried adding some code to the template to trigger if IsPost but that's not doing anything either so it's not posting back to itself either.

  • Openfield Creative 62 posts 222 karma points
    Feb 23, 2016 @ 15:05
    Openfield Creative
    0

    It's funny how you always miss the little things. I noticed that out front end mockups weren't even submitting forms so upon looking at the code a little closer I realized that our submit button wasn't a submit button but a button that said submit. As soon as I switched it to type="submit" it started submitting, now i can get my logic worked out.

Please Sign in or register to post replies

Write your reply to:

Draft