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.

Archive /

Our old forums are still available as a read-only archive.

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

Arbitrary Sort in tablefield

Go to End



Forum Moderator, 4102 Posts

7 November 2008 at 10:07am

I know TableFields don't support drag-and-drop re-ordering. That would be awesome! (next version, please?)

But until then, I want to add an arbitrary "Sort" field to my DataObjects in a TableField or CTF. Problem is, I'm not sure how to cascade an update if the user assigns a new sort order to an object that is already taken by another object. Don't want to end up with two 3's, for instance.

Anyone have any idea how to do that? I assume this is where onBeforeWrite() is handy, but that's just a guess.

The problem I'm having is making the distinction between the data supplied by the form and the data that was already on the object to begin with.

$this->Sort .. is that the old data or the new data coming in from the form?

Maybe $_POST['Sort'] is what I want?

Also, writing an efficient query seems like another chore. Any ideas?