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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

form in page action not submitting

Go to End

3 Posts   1887 Views


Community Member, 95 Posts

29 August 2009 at 4:57pm

I am trying to create a front-end page editing capability, and set things up so that would return a (secured) customized page with a form to edit the page content. the problem that i have is that when i hit submit, the page returns to the same url, and nothing gets submitted. I dont know if this is because i am submitting from a url with an action in it or what. here is the code , any help would be appreciated:

class CustomPage_Controller extends Page_Controller{
	function EditPage(){

		//this is called in a url,

		$fields = $this->EditableFields();  // correctly returns fields needed in form
		$actions = new FieldSet(
			new FormAction('UpdatePage', 'Update')
		$required = new RequiredFields(
		$form = new Form($this, "EditPage", $fields, $actions, $required);
		$newdata = array(
			'Title' => 'Editing '.$this->Title,
			'Content' => '',
			'Form' => $form
		return $this->customise($newdata)->renderWith(array('Page','Page'));
	function UpdatePage($data, $form){
	        //  ... code here, but this method never gets called...

Thanks alot,


Community Member, 283 Posts

29 August 2009 at 6:46pm

Well it seems that the way you are putting the for in through customise() is causing the form to post back to itself instead of the UpdatePage action.

See the post action in your form as rendered:

<input type="submit" title="Update" value="Update" name="action_UpdatePage" id="Form_EditPage_action_UpdatePage" class="action"/>

It sees EditPage as the form it should be calling to rebuild it and apply the data. Since your function doesn't return a Form object it just re-renders the page when it gets to the renderWith() call.

You can:
1. Move your form creation to a separate function EditPageForm and call it as a $EditPageForm in template.
2. Add the following arg to your existing code:

function EditPage($data){

The $data object will have all your posted data in the ->postVars array.

1 is the intended SS way, 2 is the QnD way. Do as you will :)


Community Member, 95 Posts

4 September 2009 at 7:00am

thanks alot dalesaurus, that helped. i ended up using the template and it worked out pretty well. thanks again,