GridField edit record set relation ID

SilverStripe 3 Gridfield is very flexible and easy to work with compared to the old ComplexTableField and popups of SilverStripe 2.4 (so far). One pitfall however is that when adding a record to a  has_many the parent ID / relation ID is not prepopulated - related ticket here.

Luckily it isn't too hard to change this behaviour by supplying a new ItemRequest class and overriding ItemEditForm()...Check out the Gist