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.

Form Questions /

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

[Solved] Custom forms 2.4.2

Go to End

4 Posts   1197 Views


Community Member, 541 Posts

29 October 2010 at 1:02am

Hi All,

Has anyone had problems creating custom forms in 2.4.2? I have a very simple form that is created in a method in my page controller. For some reason thought it doesn't seem to be calling the method specified in the action. It just seems to re-direct to the form's url with the forms method name tacked on the end?

Any ideas?



Community Member, 271 Posts

29 October 2010 at 4:00pm

Have you added the action method to the allowed actions array?


Community Member, 541 Posts

29 October 2010 at 10:18pm


I have actually tried downgrading to 2.4.1 and am getting the same problem. I don't think there is anything wrong with my code :s.

Here is my Page_Controller:

class Page_Controller extends ContentController {
    public static $allowed_actions = array(

    public function init() {

    public function guessForm() {
            $fields = new FieldSet(
                new TextField('Content','Any idea yet? Have a guess'),
                new HiddenField('OwnerID', 'ID', $this->getPlayer()->ID)

            $actions = new FieldSet(new FormAction("doSubmitGuess","Submit"));

            $validator = new RequiredFields();

            return new Form($this,"guessForm",$fields,$actions,$validator);

    public function doSubmitGuess($data,$form) {
        $guess = new Guess();


I had already got the allowed actions entry. I have also written a unit test to sets saving of $guess and its associations, which pass. It just seems the form does not process the submit action :(.

I have also tried altering "Director::redirectBack();" with no luck.

Any ideas? This has me stumped. I don't think I am making some NOOB mistake, but I might be...



Community Member, 541 Posts

31 October 2010 at 2:45am

Ok, this was just being a Noob!!

I had a method in the controller that was re-directing if the incorrect action was supplied. Obviously this re-direct happens before the POST data is processed.

All fixed now.