Hi everyone
I am trying to use sortable (drag and drop) on a dataobject. I have SS3 installed with the SortableGridField module. In the documentation it says...
"For many_many relationships you must add a $many_many_extraFields static to the data object defining the relationship, see the SilverStripe documentation for more information on this. If you are using a many_many relationship you will need to do a custom getter to set the sort order of this relationship for use on the front end..."
However I cant find any example of this in practise, has anyone done this yet?
This is in "Page.php"
$gridFieldConfig = GridFieldConfig_RelationEditor::create()->addComponents(
new GridFieldDeleteAction('unlinkrelation')
);
$gridfield = new GridField("RightCallToActions", "RightCallToAction", $this->RightCallToActions(), $gridFieldConfig);
//$gridfield->addComponent(new GridFieldSortableRows('{Column to store sort}'));
$fields->addFieldToTab('Root.RhsCTA', $gridfield);
Relationship is
public static $many_many = array(
'LowerCallToActions' => 'LowerCallToAction',
'RightCallToActions' => 'RightCallToAction'
);
public static $belongs_many_many = array(
'Pages' => 'Page'
);
In SS2.4.x i used: SortableDataObject::add_sortable_class('HotelImage'); which was super simple! Shame its not the same and you now have to add sortable bits yourself :(