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 for Custom Form


Go to End


11 Posts   8895 Views

Avatar
Sean

Forum Moderator, 922 Posts

16 January 2009 at 9:35am

Glad to see you go it working, all looks kosher. The Email class will have populateTemplate() available to it in the next 2.3.0 release.

Cheers,
Sean

Avatar
Tama

Community Member, 138 Posts

30 September 2010 at 10:43am

Liam mentioned something that I thought existed - a required class automatically added to all of the required fields in forms.

We've on 2.4.0 and I can't see the class anywhere in the HTML/CSS code or the DOM. Is there something I'm missing?

Cheers
Tama

Avatar
Tama

Community Member, 138 Posts

1 October 2010 at 3:37pm

In the end I applied the "requiredField" class (used by the custom User Forms module) with the following code:

		// Set required fields in form object and assign classes
		$requiredFieldList = array('FirstName','LastName','Email');
		
		$validator = new RequiredFields($requiredFieldList);
		
		foreach($requiredFieldList as $fieldName) {
 			$fields->fieldByName($fieldName)->addExtraClass("requiredField"); 
		} 

Thanks to this repo: http://sunny.svnrepository.com/sunny-side-up-general/trac.cgi/browser/userpage/code/RegisterAndEditDetailsPage.php?rev=73

Go to Top