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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Form Questions /

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

all fields are Validating as email address

Go to End

2 Posts   953 Views


Community Member, 99 Posts

13 May 2010 at 7:36pm

I have added a contact form to a page but all fields are validating with "Please enter an email address."

Obviously I must be missing something

page.php +++++++++++++++++++++

class Page_Controller extends ContentController {
public function ValuationForm()
return new ValuationForm($this,'ValuationForm');




class ValuationForm extends Form {

function __construct($controller, $name) {
$fields = new FieldSet(
new TextField('Name', 'Name'),
new EmailField('Postcode', 'Postcode'),
new EmailField('Email', 'Email'),
new EmailField('Telephone', 'Telephone')


$actions = new FieldSet(
new FormAction('submit', 'Submit')

// Create validator
$validator = new RequiredFields('Email');

parent::__construct($controller, $name, $fields, $actions, $validator);

function forTemplate() {
return $this->renderWith(array(

function submit($data, $form) {
$valuation = new Valuation();
//$valuation->JobCategoryID = $this-dataRecord->ID;
$form->sessionMessage('Form successfully submitted', 'good' );

// do stuff here



Community Member, 99 Posts

13 May 2010 at 7:39pm

all that and its staring me in the face

new EmailField('Postcode', 'Postcode'), should be TextField('Postcode', 'Postcode')