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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

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

Validation requires page refresh?


Go to End


1950 Views

Avatar
digibrains

Community Member, 130 Posts

10 August 2010 at 9:16am

Edited: 10/08/2010 1:08pm

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;
	}