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.

Archive /

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

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

About Forms, Validator and FormFields


Reply


782 Views

Avatar
dio5

Community Member, 501 Posts

14 October 2008 at 8:07am

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.