Jump to:

1970 Posts in 1272 Topics by 607 members

Form Questions

SilverStripe Forums » Form Questions » Validation requires page refresh?

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

Page: 1
Go to End
Author Topic: 980 Views
  • prawnstar
    Avatar
    Community Member
    116 Posts

    Validation requires page refresh? Link to this post

    I'm trying to validate a form that is inside a modal window, but on submit the page refreshes.

    basically the problem goes like this:
    1. user mouses over event trigger, the form shows in a modal window.
    2. user fills in the form and clicks submit.
    3. page refreshes and modal window is now gone.

    obviously i'd prefer to not have the modal window disappear, which means i'd rather not have a page refresh. BUT if that's the only way possible i can live with that. however, when the page refreshes and there *is* an error, the error is shown just before page refresh and when the refresh is finished and a user mouses back over the modal form it displays with a single dot instead of the error message.

    see attached.

    it should be noted that i'm also using the jquery library for other javascript goodness. is my only option to use the jquery.validate library?

    any help is appreciated.

    chris.b

    EDIT: These are my form functions that are inside my Page.php Controller, The $Form is being called from my HomePage.ss.

    // Form for the email signup
       function Form() {
          $fields = new Fieldset(new Textfield ('ConnectBoxEmail', 'Email'));
          $actions = new Fieldset(new ImageFormAction('doSubmitConnect','','themes/mytheme/images/newsletterSignup.gif','','',''));
          $validator = new RequiredFields('ConnectBoxEmail');
          $form = new Form($this,'Form',$fields,$actions,$validator);
          return $form;
       }

    // Form processor for email signups
       function doSubmitConnect($data, $form) {
          $connect = new EmailCollect();
          $form->saveInto($connect);
          $connect->write();
          $form->sessionMessage('Form successfully submitted','good');
          Director::redirectBack();
          return;
       }

    980 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.