Developer forum

Forum » Feature requests » Forms for Editors in Ecommerce product template

Forms for Editors in Ecommerce product template

Anders Engelbøl
Reply

Hi, I apologize a bit in advance for sounding a bit cross, but it's been a long wait and a rather long process for a (in my mind at least) simple thing.

 

The scenario:

I've created a form via Forms of Editors, and a product template in which I've include this as a Global:Paragraph.Content tag referring to the paragraph in question. As a result, the form should be part of the product template from which I can send information from the product template directly via the URL (for example). A simple contact form if you will. The template design does not allow me to include the form as a separate paragraph on the product details page layout. This would otherwise have been optimal.

 

The issue:

The problem is that the form renders on the page without problems (and is not a form included inside another form by the way). It just doesn't submit any data. If you take a look through the browser inspector the data from the form is picked up nicely as it should, it's just never submitted properly, no redirect to any receipt (if set up), and of course no mail recieved from the form. It just redirects to the original page ID.

 

My annoyance:

This is where I contacted DW engage describing the above. I recieved the answer of (roughly) "You are trying to receive data from the form's module in our product catalog. It is not something we support out of the box." As such, this would have been a sufficient answer, if it was not for the fact that the former forms module performed this task perfectly.

Now, I know that you encourage us to use your latest modules, and don't get me wrong, I think that is the right way to go. I want to use your latest modules. But when the answer is "It is not something we support out of the box." ..and a reference to the forum, I would rather classify this as a core code bug, than a feature request. I mean, when the former module performs the specific task better than the new, it's a step back.

 

The workaround:

I basically have two choices. Either to go with the former forms module, without any options to enhance the mail templates etc. Or, I could split the product template into two, placing the form in between two eCom modules, slashing performance in the process. I'd rather not choose any of those options.

 

So, as I said, sorry for the irritation, but I've spent way too much time on this case than should have been necessary by now. 

Case ref: 114830

 

 

 


Replies

 
Nicolai Høeg Pedersen
Reply

HI Anders

The form needs to submit to the page in which it resides. So if your paragraph is attached to a paragraph on page with id 123, the form needs to post to that page. If you do that, it should work.Of course the forms module needs to be on the page you submit the data to.

You can also have the form on your product page directly and move it from one template to another using Snippet tag:

http://templates.dynamicweb.com/TemplateTags/Dynamicweb-template-tags/General-tags/Snippet.aspx

BR Nicolai

 
Anders Engelbøl
Reply

Hi Nicolai,

Let me pinpoint it once again: 

As such, this would have been a sufficient answer, if it was not for the fact that the former forms module performed this task perfectly. - See more at: http://developer.dynamicweb.com/forum.aspx?ThreadID=45495#sthash.Epu1YBvq.dpuf

At least explain to me why this works without a hitch when the new module can't.

Regarding the reference to snippets, this wouldn't exactly help me, as it would serve the exact same purpose as a global paragraph. I am not trying to include the form directly on the product page as I would end up with the above scenario:

Or, I could split the product template into two, placing the form in between two eCom modules, slashing performance in the process - See more at: http://developer.dynamicweb.com/forum.aspx?ThreadID=45495#sthash.Epu1YBvq.dpuf

Basically, I'm trying to place one form on all product templates, not the other way around. Would you take a closer look at it, maybe the case reference could clarify further?

 
Anders Engelbøl
Reply

Taking a closer look at the .cshtml template, the page.ID posted from the form is included form the page where the form resides, but should take the page ID from where the form is included (or submitted from). Do you have any suggestion on a rewrite of the @formOnSubmit function from the DefaultFormTemplate.cshtml template into something useful?

 
Nicolai Høeg Pedersen
Reply

Having a bad day?

The old forms module posts to /Admin/Public/Formmail.aspx and there is a lot of issues regarding this because of span, pagelife cycles, context (culture, login info, domain infos, areas) and so on. Therefore the new forms module posts to Default.aspx?ID=XX the page where the form it self resides. In this way the forms module has access to all the right things in the context. So if you include it as a global paragraph the forms gets the id of the page where it is included instead of the page at which the paragraph with the form is located - and as a result it posts the form to the page it is included which do not have the forms module attached to handle that post. That can be changed in the template very simple by changing the ID of where the form is posted.

Rendering the form using a global paragraph or on the same page results in the exact same performance. It is the same code that gets executed.

I do not know your setup, but if you have i.e. one page with the product catalog, you can on the same page add the forms module - and use snippets to move inside the product template. That is what snippets do - move content.

So in your forms template do this:

<!--@SnippetStart(myform)-->
...your form template code...
<!--@SnippetEnd(myform)-->

And in your product template like this:

<!--@Product.Name--><!--Snippet(myform)-->

This way, the form gets rendered in the form template, but 'moved' inside the product template. No need to split the template in 2.

BR Nicolai

 
Nicolai Høeg Pedersen
Reply

You can replace the page id with a replace method on the formOnSubmit string, see dump.

<form method="post" action="@formAction" enctype="multipart/form-data" class="@formCssClass" id="@formId" onsubmit="@formOnSubmit.Replace("?ID=11418", "?ID=959595")">

Capture.PNG
 
Anders Engelbøl
Reply

Hi Nicolai,

Sorry, not having a bad day. Just being bounced around a bit in the support system in search for an answer, so trying to get to the heart of the problem, so the issue can be resolved. I'll try the above. Thank you.