Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » Augmenting Validation on Subclassed Custom Forms

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

Page: 1
Go to End
Author Topic: 404 Views
  • zenmonkey
    Avatar
    Community Member
    528 Posts

    Augmenting Validation on Subclassed Custom Forms Link to this post

    I have a cusrtom form, with multiple subclasses forms that I want to augment the Validation porion on the sublcasses, but I'm not sure how to go about it.

    The Custom Form

    class LeadCaptureForm extends Form {
       
       public function __construct($controller, $name) {

          $fields = new FieldList(
             $holder
          );
          
          $actions = new FieldList(
           FormAction::create("leadSubmit")->setTitle($controller->FormButton)->setUseButtonTag(true)->addExtraClass('button red small point-right')
          );
          
          
          $validation = new RequiredFields(array('Email'));
          
          parent::__construct($controller, $name, $fields, $actions, $validation);
       
       }

    The sublcassed forms look like this

    class MarketForm extends LeadCaptureForm {
       function __construct($controller, $name) {
          
          parent::__construct($controller, $name);

          $newfields = new CompositeField(
             $house,
             $homedeet,
             $propDeets
          );
          
          $this->Fields()->insertBefore($newfields, "main");
          
          
       }
    }

    On the MarketForm I'd like to add a few of the LeadCaptureForms to the validation as well as the the fields from MarketForm.

    404 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.