Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » userforms misses validate function when included in other template

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 210 Views
  • s_a_m_y
    Avatar
    Community Member
    25 Posts

    userforms misses validate function when included in other template Link to this post

    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 %>
       $Form
    <% 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.

    Thanks,
    Sam

  • s_a_m_y
    Avatar
    Community Member
    25 Posts

    Re: userforms misses validate function when included in other template Link to this post

    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:

    Requirements::javascript('userforms/thirdparty/jquery-validate/jquery.validate.js');
    Requirements::add_i18n_javascript('userforms/javascript/lang');
    Requirements::javascript('userforms/javascript/UserForm_frontend.js');
    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...

    210 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.