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.

Customising the CMS /

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

Save multiple Records from a TableField


Go to End


1052 Views

Avatar
cornJ

Community Member, 3 Posts

1 December 2010 at 4:30am

Edited: 01/12/2010 4:31am

Most probably a stupid question again:

I have a Form with a TableField in the CMS where a user can modify the values of a set of records at the same time. Now how do I (elegantly) save the changes back to the database?

My first attempt was to loop over the returned data, get every changed DataObject via its ID and save the changed data. This works... but there is a prettier way, isn't there?

Anyway if not, I still got one problem: The Form recognizes the changes setting the status to unsaved (in javascript). But it does not recognize the save action. Becaus the saveing is done with ajax i have to put some javascript into my answer telling the form to set the status back to saved, so the anoying "not saved warning" does not appear on leaving the page.

showMessage("Saved") shows the message, I found out. But what snippet changes the status?