Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » RequiredFields

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

Page: 1
Go to End
Author Topic: 433 Views
  • TDNP
    Avatar
    Community Member
    19 Posts

    RequiredFields Link to this post

    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?

    433 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.