Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » Custom Form Loses values after validation

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

Page: 1
Go to End
Author Topic: 368 Views
  • VicfromPerth
    Community Member
    8 Posts

    Custom Form Loses values after validation Link to this post

    I have a custom order form that does everything okay except when one of the required fields is not entered and the validation kicks in, I lose the values from all the other fields. My form fields are created like so:

    new TextField('Company','Company'),
    new TextField('Contact', 'Contact'),
    new TextareaField('Company_Address', 'Company Address'),

    And the form is constructed the following way:

    $requiredFields[] = 'Company';
    $actions = new FieldSet(new FormAction('processOrder', _t('OrderForm.PROCESSORDER','Place order')));
    $validator = new OrderForm_Validator($requiredFields);
    parent::__construct($controller, $name, $fields, $actions, $validator);
    if($this->extend('updateFields', $fields) !== null) {$this->setFields($fields);}
    if($this->extend('updateActions', $actions) !== null) {$this->setActions($actions);}
    if($this->extend('updateValidator', $validator) !== null) {$this->setValidator($validator);}

    I have tried removing the lines from the form action script that clears the session data, but that has not helped.
    It seems that the javascript validation does not actually kick in and it gets validated server side, but not sure how to make the javascript validation kick in.

    Any help would be great!

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.