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.

Form Questions

RequiredFields


Reply

447 Views

Avatar
TDNP

5 January 2012 at 11:03am (Last edited: 5 January 2012 11:04am), Community Member, 19 Posts

Before you say it, I've looked through the forums and haven't found why this would be happening.

$fields = new FieldSet(
   new TextField('FirstName', 'First Name*'),
   new TextField('LastName', 'Last Name*'),
   new TextField('Business', 'Business Name'),
   new TextField('Address', 'Full Address*'),
   new TextField('Address2', 'Address Continued'),
   new TextField('City', 'City'),
   new TextField('State', 'State'),
   new TextField('Zip', 'Zipcode'),
   new NumericField('HomePhone', 'Home Phone* (No Dashes)', null, 9),
   new NumericField('CellPhone', 'Cell Phone', null, 9),
   new EmailField('Email', 'Email Address*')
);
// Create action
$actions = new FieldSet(
   new FormAction('XMLWrite', 'Submit')
);
         
// Create validator
$validator = new RequiredFields('FirstName', 'LastName', 'Address', 'HomePhone', 'Email');
            
return new Form($this, 'DonationForm', $fields, $actions, $validator);

The form renders properly but the validation doesn't work. I can tab through the fields and submit the form without being required to enter any data. I don't want to write a validation script knowing that SS has one built in. Also, I have this working in a contact form on the same site. I've double and triple-checked my typing but after a while, my eyes get numb to reading the same code over and over. Can anyone offer a little help here?