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.

All other Modules /

Discuss all other Modules here.

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

UserForms - loaded into other page


Go to End


4 Posts   1660 Views

Avatar
borriej

Community Member, 267 Posts

1 November 2011 at 2:57am

Edited: 14/12/2011 11:26am

Hello,

I have a reservation form which is on [removedMyUrl]
Everything is very nicely styled with css, also the custom errors are set.

Now i have a pageType 'Diensten' where I want to include this form at the bottom of the page.

So i use:
Diensten.php

class Diensten_Controller extends Page_Controller {
	
   function ShowForm(){
		$get = DataObject::get_one('UserDefinedForm');
		return new UserDefinedForm_Controller($get); 
	}
   
}

Diensten.ss

            <% control ShowForm %>
            $Form
            <% end_control %>            

See
[removedMyURL]

The form shows on all pages, BUT:
- the custom error messages are the default onces, not the onces i've set
- the styling of the error message is different

WHY? and HOW can i fix this?

Avatar
borriej

Community Member, 267 Posts

14 December 2011 at 3:17am

UP! Still need a fix for this :(
The validation works more-or-less, but I get the default errors and the datePicker isnt working! The checkbox is required, but it isn't required when the form is loaded through showForm(); this is not my intention.

Any one? Willr?

Avatar
Martijn

Community Member, 271 Posts

14 December 2011 at 5:13am

you need to block the prototype validation and add the jquery javascript
see UserDefinedForm_Controller init:

// block prototype validation
Validator::set_javascript_validation_handler('none');

// load the jquery
Requirements::javascript(SAPPHIRE_DIR .'/thirdparty/jquery/jquery.js');
Requirements::javascript('userforms/thirdparty/jquery-validate/jquery.validate.min.js');

Avatar
borriej

Community Member, 267 Posts

14 December 2011 at 5:32am

works like a charm!! thank you so much!