Formbuilder Redirect Error If Form Not Filled In Correctly

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
govicinity
Forum Members
Forum Members
Posts: 119
Joined: Tue Nov 22, 2011 2:22 pm

Formbuilder Redirect Error If Form Not Filled In Correctly

Post by govicinity »

CMS Made Simple™ 2.1.6 “Spanish Wells”
PHP Version 5.6.30
AceEditor2 1.05
AdminSearch 1.0.2
CGBlog 1.14
CGSimpleSmarty 2.1.6
CGSmartImage 1.21.8
CMSContentManager 1.1.4
CMSMailer 6.2.14
Captcha 0.5.5
DesignManager 1.1.1
FileManager 1.5.2
FormBuilder 0.8.1.6
JQueryTools 1.4.0.1
LISE 1.2.3
MenuManager 1.50.2
MicroTiny 2.0.3
ModuleManager 2.0.5
Navigator 1.0.3
News 2.50.6
Search 1.50.2
SiteMapMadeSimple 1.2.8
TinyMCE 3.1.4
Uploads 1.25.4.1

Odd query this one, it's to do with Formbuilder, Captcha and the detail template I have created in LISE.

If I do not fill in the form correctly I assumed that the page http://krb.govicinity.com/vacancies/acc ... r-312.html would simply reload and tell me the form had not been filled in properly (keeping it's current dynamically created LISE URL), but instead I am getting sent back to this page http://krb.govicinity.com/moduleinterface.php which I certainly do not want to go back to! It loses all the style of course, as my template for the individual job listing pages are mainly in a LISE detail template.

The form is not set to appear inline, but if I do do that it completely loses the form... which it would do as the form is in the detail template in LISE.

This website is complete apart from this issue.

08. Vacancies Smarty Page Only (the template for the page)

Code: Select all

{process_pagedata}
<!DOCTYPE html>
<__html lang="en">
{content label='This is the smarty tag area - please do not touch this, you may break your site if you do' oneline='true' wysiwyg='false'}
</__html>
{/strip}
The LISE detail template

Code: Select all

<head>
<meta name="description" content="{$item->fielddefs.description.value|truncate:150:true|strip_tags}" />
<meta name="keywords" content="{$item->fielddefs.description.value|truncate:150:true|strip_tags}" />
{metadata}
</head>

</__body class="{$page_alias}">
<div id="wrapper">

{global_content name='Header'}

<div class="wrapper-inner">

{* Start Content *}
<article>

<div class="single-column">

<h1>{$item->fielddefs.jobtitle.value}</h1>

<div class="double-column">
    <div class="grid-50">
        <p>Location: {$item->fielddefs.location.value} <br />
        Salary: {$item->fielddefs.salary.value}<br />
        Reference: {$item->fielddefs.jobreference.value}</p>
        {$item->fielddefs.description.value}
    </div>
    <div class="grid-50">
        <__iframe src="{$item->fielddefs.jobmap.value}" allowfullscreen class="job-map"></__iframe>
        {FormBuilder form='krb_job_form'}
    </div>
</div>

{assign var='alt_title' value=$entry->title}

</div>

</article>
{* End Content *}

</div>
</div>

{global_content name='Footer'}

{global_content name='Scroll_To_Top'}
{/strip}
<__body>
Going up, woop, woop.
User avatar
Rolf
Dev Team Member
Dev Team Member
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: Formbuilder Redirect Error If Form Not Filled In Correct

Post by Rolf »

This article describes the use and re-use of variables from modules and page templates
https://www.cmscanbesimple.org/blog/bas ... d-metatags

If you check the page source of your site you will see that the form is sent from the detailpage. To change this to the canonical URL you can replace it with Smarty like:

Code: Select all

{Formbuilder|replace:'http://krb.govicinity.com/vacancy-details.html':$canonical_url ...}
Note: $canonical_url is an example of my tutorial I posted.
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
govicinity
Forum Members
Forum Members
Posts: 119
Joined: Tue Nov 22, 2011 2:22 pm

Re: Formbuilder Redirect Error If Form Not Filled In Correct

Post by govicinity »

OK, so I now know why the page redirects to the default "container"/template page on submission:

Code: Select all

<form id="cntnt01moduleform_1" method="post" action="http://krb.govicinity.com/vacancy-details.html" class="cms_form" enctype="multipart/form-data">
i.e. the form is pointing to the vacancy-details.html page rather than the actual dynamically created http://krb.govicinity.com/vacancies/acc ... r-312.html one, is there any way to make the system do this? Otherwise I am stuffed!
Going up, woop, woop.
govicinity
Forum Members
Forum Members
Posts: 119
Joined: Tue Nov 22, 2011 2:22 pm

Re: Formbuilder Redirect Error If Form Not Filled In Correct

Post by govicinity »

Thanks Rolf, I have taken some of what you have said and used it to make the URLs work well, if I did exactly as you said for some reason it still returned the http://krb.govicinity.com/vacancy-details.html URL.

Here's what I have done so far:

Above doctype:

Code: Select all

{process_pagedata}
{$canonical_url = "{root_url}{$smarty.server.REQUEST_URI}" scope=global}
In head

Code: Select all

<link rel="canonical" href="{$canonical_url}">
In formbuilder call:

Code: Select all

{FormBuilder|replace:'http://krb.govicinity.com/vacancy-details.html':$canonical_url form='krb_job_form'}
So that's got the exact URL in now, is that OK, or will what I have done cause issues?

One thing still puzzles me though, when I submit the form incomplete the page reloads with nothing else on it at all but the form, so I guess it is losing the template I have in LISE which has all of the information in it about the job, the form, the header and footer etc. Is there any was to keep that all there? because I know at some point someone is going to submit the form wrongly, so I need to fix this.

So all that's in the page template that handles the actual job details is this:

Code: Select all

{process_pagedata}
{$canonical_url = "{root_url}{$smarty.server.REQUEST_URI}" scope=global}
<!DOCTYPE html>
<__html lang="en">
{content label='This is the smarty tag area - please do not touch this, you may break your site if you do' oneline='true' wysiwyg='false'}
</__html>
{/strip}
Everything else is in a LISE detail template like this:

Code: Select all

<head>
{strip}
<meta name="description" content="{$item->fielddefs.description.value|truncate:150:true|strip_tags}" />
<meta name="keywords" content="{$item->fielddefs.jobtitle.value}" />
<meta charset="UTF-8" />
<title>{$item->fielddefs.jobtitle.value} - {sitename}</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0, user-scalable=no">
<meta name="googlebot" content="index,follow" />
<meta name="robots" content="index,follow" />
<meta name="revisit-after" content="7 Days" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta property="og:url" content="{root_url}{$smarty.server.REQUEST_URI}" />
<meta property="og:title" content="{$item->fielddefs.jobtitle.value}" />
<meta property="og:site_name" content="{sitename}"/>
{if !empty($Meta_Description)}
<meta property="og:description" content="{$Meta_Description}"/>
{/if}
<meta property="og:locale" content="en_GB" />
{cms_stylesheet}
{literal}
<__script__ src="http://krb.govicinity.com/js/modernizr.js" type="text/javascript"></__script>
<__script__ src="http://krb.govicinity.com/js/respond.min.js" type="text/javascript"></__script>
<__script__ src="http://krb.govicinity.com/js/jquery-2.2.4.min.js"></__script>
<__script__ src="http://krb.govicinity.com/js/easing.js" type="text/javascript"></__script>
<__script__ src="http://krb.govicinity.com/js/jquery.ui.totop.js" type="text/javascript"></__script>
<__script__ src="http://krb.govicinity.com/js/classie.js" type="text/javascript"></__script>
<__script__ src="http://krb.govicinity.com/js/smaller.js" type="text/javascript"></__script>
<__script__ type="text/javascript">
$(document).ready(function(e) {
 $('img').css('opacity',0); // hide all images
});
$(window).load(function() {
 $('img').animate({'opacity':1},800); // everything is loaded, fade images in
});
</__script>
<__script__ defer src="http://krb.govicinity.com/js/jquery.flexslider.js"></__script>

{/literal}
<link rel="canonical" href="{$canonical_url}">
{/strip}

</head>

</__body class="{$page_alias}">
<div id="wrapper">

{global_content name='Header'}

<div class="wrapper-inner">

{* Start Content *}
<article>

<div class="single-column">

<h1>{$item->fielddefs.jobtitle.value}</h1>

<div class="double-column">
    <div class="grid-50">
        <p>Location: {$item->fielddefs.location.value} <br />
        Salary: {$item->fielddefs.salary.value}<br />
        Reference: {$item->fielddefs.jobreference.value}</p>
        {$item->fielddefs.description.value}
    </div>
    <div class="grid-50">
        <__iframe src="{$item->fielddefs.jobmap.value}" allowfullscreen class="job-map"></__iframe>
        {FormBuilder|replace:'http://krb.govicinity.com/vacancy-details.html':$canonical_url form='krb_job_form'}
    </div>
</div>

</div>

</article>
{* End Content *}

</div>
</div>

{global_content name='Footer'}

{global_content name='Scroll_To_Top'}
{/strip}
<__body>
Any thoughts?
Going up, woop, woop.
User avatar
Rolf
Dev Team Member
Dev Team Member
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: Formbuilder Redirect Error If Form Not Filled In Correct

Post by Rolf »

Some templating basics:

1. The Core::Page template should build up your page lay-out and contain the < html >, < head > and < body > parts.

2. Module templates should only contain the code needed for the module output!

3. Call the modules *in* a Core content block.


For the use of template inheritance the {content} block should be parsed by Smarty. That is described in the blog post of mine mentioned above.


More useful information:
https://www.cmscanbesimple.org/blog/use ... ent-blocks

https://www.cmscanbesimple.org/blog/the ... gn-manager
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
govicinity
Forum Members
Forum Members
Posts: 119
Joined: Tue Nov 22, 2011 2:22 pm

Re: Formbuilder Redirect Error If Form Not Filled In Correct

Post by govicinity »

OK, so gone back to basics on his now, used your template page layout Rolf, all working well apart from the canonicals still, I am pretty sure I have exactly as you have on your page.

Process pagedata

Code: Select all

{process_pagedata}
{$canonical_url = "{$content_obj->GetURL()|lower|default:''}" scope=global}
{$root_url = "{root_url}" scope=global}
{$site_name = "{sitename}" scope=global}
{$page_description = "{description}" scope=global}
{$page_lang = 'en' scope=global}
{$page_title = "{title}" scope=global}
{$content = "{content label='This is the smarty tag area - please do not touch this, you may break your site if you do' oneline='true' wysiwyg='false'}" scope=global}
Global Metadata

Code: Select all

<meta charset="UTF-8" />
<meta name="copyright" content="XXXXXX">
<meta name="description" content="{$page_description}">
<meta name="keywords" content="{$page_description}">
<link rel="canonical" href="{$canonical_url}">
{/literal}
LISE detail element

Code: Select all

{$canonical_url = $entry->canonical|lower scope=global}
{$page_description = $entry->content|default:$entry->content|strip_tags|strip|truncate:150 scope=global}
{$page_title = $item->fielddefs.jobtitle.value scope=global}
<h1>{$page_title}</h1>
<p>Location: {$item->fielddefs.location.value} <br />
Salary: {$item->fielddefs.salary.value}<br />
Reference: {$item->fielddefs.jobreference.value}</p>
{$item->fielddefs.description.value}
<__iframe src="{$item->fielddefs.jobmap.value}" allowfullscreen class="job-map"></__iframe>
Head

Code: Select all

<head>
<title>{$page_title} - {$site_name}</title>
<meta charset="utf-8">
{metadata}
{cms_stylesheet}
</head>
Body

Code: Select all

</__body class="{$page_alias}">
<div id="wrapper">
{global_content name='Header'}
<div class="wrapper-inner">
{* Start Content *}
<article>
<div class="single-column two-column">
<div class="smarty-column">
<h1>{$page_title}</h1>
{$content}
</div>
{Formbuilder|replace:'http://krb.govicinity.com/vacancy-details.html':$canonical_url form='krb_job_form'}
</div>
</article>
{* End Content *}
</div>
</div>
{global_content name='Footer'}
{global_content name='Scroll_To_Top'}
<__body>
</__html>
So I have the page title coming in nicely, I have the content of the page filling the description and the keywords with the body content, the only thing I can see that's not working is the canonicals... and when you submit the page without filling it fully still it gets the summary results in it rather than keeping the job that was originally by the form (i.e. the job the form is actually about).
Going up, woop, woop.
govicinity
Forum Members
Forum Members
Posts: 119
Joined: Tue Nov 22, 2011 2:22 pm

Re: Formbuilder Redirect Error If Form Not Filled In Correct

Post by govicinity »

So for a little more information on the detail vacancies page I have this smarty call:

Code: Select all

{LISEVacancies orderby="item_position" detailpage="vacancy-details"}
To bring in the detail of the job, but as explained earlier, when you submit the sorm incorrectly the details of the job disappear and the summary is brounght into the page instead, I'm sure it's a simple coding slip from me, but I can't put my finger on it, the pages are set to not cache, see the page here and try it for yourself:
http://krb.govicinity.com/vacancies/bookkeeper-318.html

Even if I use replace on the form so that the URL stays the same it still seems to reload the summary in the left hand side of the column unfortunately.
Going up, woop, woop.
govicinity
Forum Members
Forum Members
Posts: 119
Joined: Tue Nov 22, 2011 2:22 pm

Re: Formbuilder Redirect Error If Form Not Filled In Correct

Post by govicinity »

OK, so been scratching my head for about a week on this now, it seems that as the page refreshes on form submission (whether it is filled in correctly or not) then we get the summary load in the left part of the page where the detail job description was previously.

my work-around is this article on i-do-this:
https://www.i-do-this.com/blog/AJAX-For ... builder/57
That basically stops page reload on page submission using AJAX, credit to Ken Griffith for his solution, and also for being the saviour of my sanity, and to Rolf for his help on the template.
Going up, woop, woop.
Post Reply

Return to “Modules/Add-Ons”