Forms module just going to blank screen

edited October 2015 in Modules
I've included the newsletter modules in my site, and the form is coming through correctly. No errors in the console. Although when I submit, the page is emptied and all is left is a white screen. I'm initialising with:

$vars['form_newsletter'] = $this->fuel->forms->create('newsletter', array( 'fields' => array( 'name' => array('required' => TRUE), 'email' => array('required' => TRUE), ) ));

and in my view:

<?=$form_newsletter->render()?>

On submit, I get a 'Uncaught TypeError: Cannot read property 'add' of null' in the console.

Comments

  • edited 7:46PM
    I've included a video if that helps, just in case I'm not clear: http://webmshare.com/8LXLg
  • Are you sure it's displaying the view you think it is? Stick an extra echo 'BOO!!' just to see what you get.

    The video is a nice idea but it would help to see the page URL and the console output too ;)
  • edited October 2015
    Haha okay, I'm not sure where I would echo that 'boo' out if you follow me. The URL stays the same, and after I've submitted the form the page refreshes and I'm left with:

    <html><head><script type="text/javascript" charset="utf-8" src="/fuel/modules/fuel/assets/js/jquery/plugins/jquery-migrate-1.1.1.js?c="></script></head></html>

    Here's before the form submit, and after: https://imgur.com/a/j4Giy

    I'm on the develop branch of FUEL if that matters.
  • edited 7:46PM
    What is the URL you are seeing that it submits to? If you try specifying a "return_url" parameter, does it redirect to the specified page?
  • edited October 2015
    Okay, fixing the issue in the other thread seems to have solved this one too. Coming back to re-create it it seems to be working. So, thanks for the help but I can't reproduce it any more.

    On the newsletter though, I have one more question. I'm linking out to jQuery at the bottom, just before the closing body tag, and printing out the form near the top of the page using the $this->fuel->forms->create() helper. Although this helper sends along jquery validate, additional-methods.js, jquery forms, and forms.js alongside some inline js too, which is breaking since jQuery isn't defined yet. Is there anyway to defer these to the footer?

    I'm using

    <?=jquery()?> <?=js($js)?>

    in my footer to generate all my javascript
  • edited 7:46PM
    You may need to load just jquery at the top to get that to work.
  • edited October 2015
    Okay, I'll have to do that. Thanks.

    Although now the original issue is back, and I can't see what I've changed. I'm using:

    echo form('newsletter');

    Although, if I use:
    $form = $this->fuel->forms->create('newsletter'); echo $form->render();

    Only the "Submit" button is printed out.

    If I toggle the "Javascript submit" to no in the admin panel, then it works. If I select yes, then after the form it's just a white page. If you want a live preview just let me know?
  • edited 7:46PM
    Is this on a page created in the CMS that has Cache set to "yes" by chance? Also, does the entire page refresh to be blank or is it perhaps something in the callback of the javascript ajax submission?
  • edited October 2015
    This is actually just in a _block I've created, it's my sidebar. It's loaded in on each view with:

    <?php $this->load->view('_blocks/sidebar', $sidebar); ?>

    $sidebar isn't related to the newsletter, as it's an array of data containing the recent posts, recent comments, etc. that is built up in a controller.

    It doesn't refresh, or at least a new history state isn't triggered.
  • edited 7:46PM
    I think I'll need a live preview to understand the issue.
Sign In or Register to comment.