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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

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

Passing ID into Form Issues


Go to End


2 Posts   2137 Views

Avatar
rbquirke

Community Member, 70 Posts

8 November 2009 at 5:23pm

Hi folks

I have a form on the front end which is used to edit dataobjects, so what I am doing is passing in the ID to the url of the form: edit-account/edit/$ID

So the $ID is passed in to the form and it is loaded with the correct values - this all works fine.

When I go to save the form, the page is blank with no markup whatsover (site is in dev mode), and this is the url: edit-account/Form

Both form and save form functions are contained in my page_controller class.

Now, when I take out the $ID in the url and hard code this value into the form, I can edit my dataobject no problem - it saves fine.

So it seems that have the $ID at the end of the page that calls the form is what is breaking it.

Anyone have any ideas?

Thanks

Avatar
JimAasheim

Community Member, 12 Posts

31 January 2010 at 4:23am

Hi,

I had the same problem.

What does your form code look like?
It also needs to return the form object after you submitted the form (just make sure it's not filled again with the old values from the database).
After the form function SS calls the "action function", i.e. the function the save button calls.

So what I did was, make sure the form function returns a valid form after the button click.
Then in the doSave - or whatever you called it - implement the necessary code.

Hope this could help - or post your code and I'll have a look at it.