1779 Posts in 582 Topics by 556 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 661 Views |
-
[Solved] Custom forms 2.4.2

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?
Mo
-
Re: [Solved] Custom forms 2.4.2

29 October 2010 at 4:00pm
Have you added the action method to the allowed actions array?
-
Re: [Solved] Custom forms 2.4.2

29 October 2010 at 10:18pm
Yep.
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(
'guessForm'
);public function init() {
parent::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();
$validator->set_javascript_validation_handler('none');return new Form($this,"guessForm",$fields,$actions,$validator);
}public function doSubmitGuess($data,$form) {
$guess = new Guess();
$form->saveInto($guess);
$guess->write();Director::redirectBack();
return;
}
}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...
Mo
-
Re: [Solved] Custom forms 2.4.2

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.
Mo
| 661 Views | ||
|
Page:
1
|
Go to Top |


