Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

userforms misses validate function when included in other template

Go to End

2 Posts   2032 Views


Community Member, 31 Posts

8 May 2014 at 9:51pm

I have done many pages with userforms and it usually works like a charm (so thanks for the great work!).
This time my client wants an more or less infinite scroll home page that includes the form (on top of having it as a separate page). So I integrated it like this in my Home.php:

function ShowForm(){
    $get = DataObject::get_one('UserDefinedForm');
    return new UserDefinedForm_Controller($get); 

and like this in the template:

<% control ShowForm %>
<% end_control %>

If I go to the separate form page I don't get any errors. But on the integrated part I now get a "Uncaught TypeError: undefined is not a function " and it points to the

(function($) {
	$(document).ready(function() {
		$("#Form_Form").validate({ ...

There are two validate folders - one in the framework/thirdparty and one in the userform/thirdparty. I'd be thankful for hints what is going wrong here.



Community Member, 31 Posts

8 May 2014 at 10:02pm

Edited: 08/05/2014 10:06pm

Ok. so obviously I need to include all the scripts manually to my template... I had hoped that could somehow be avoided.
So I just added this to my Home_Controller:

if($this->HideFieldLabels) Requirements::javascript('userforms/thirdparty/Placeholders.js/Placeholders.min.js');

As I have already included jquery beforehand I didn't do it here. But of course that is also needed. Maybe it will help someone else...