Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » About Forms, Validator and FormFields

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 740 Views
  • dio5
    Avatar
    Community Member
    501 Posts

    About Forms, Validator and FormFields Link to this post

    Ok, I'm running into a little issue.

    I'm having a custom form (new Form(Fields, Actions etc.. ), which uses a custom subclass of Form (MyForm extends Form).

    This form also uses MyValidator, which is a subclass of RequiredFields.

    Now, in this validator I'm throwing a validation error and setting a session var, which I access in the __construct method of MyForm. If this session var is there, I'm pushing a new Field to the form, in the constructor method of the form class, put simply:

    class MyForm extends Form{
    function __construct(){
    if (session) $fields->push(...);
    }
    }

    So far everything works.

    The page is redirectedBack, with the new Field added to the existing form.

    Then in MyValidator, I want to check if this new field is there - based upon this the validation will change. However - I'm not able to detect this field, only the fields I created initially on my controller are accessible through $data/ $this->form->Fields()->datafieldbyName("MyField").
    Neither is this field's custom validation working.

    The only thing I can do is access the value through $_REQUEST[], but not with any of the available SS methods.

    Any hints? I really want to detect if the new field is there.

    PS: I noticed the securityfield is 'pushed' in the same way in the form class, and doesn't seem to be accessible either.

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