Can this be used in ModelAdmin? I've got the module, added the init and it doesn't do anything to the scaffolded has_many items...
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.
- Previous 10 entries
- 1
- Page 22(current)
*bump*
Brice? Please help your module looks awesome and I'd love to get it working!
here is my code (and attached) with a fresh 2.4.5 install....
<?php
class DataObjectA extends DataObject {
static $db = array(
'Name' => 'Varchar'
);
static $has_many = array(
'DataObjectB' => 'DataObjectB'
);
}
<?php
class DataObjectB extends DataObject {
static $db = array(
'Name' => 'Varchar'
);
static $has_one = array(
'DataObjectA' => 'DataObjectA'
);
}
<?php
class MyAdmin extends ModelAdmin {
static $managed_models = array(
'DataObjectA',
);
static $url_segment = 'myadmin';
static $menu_title = 'MyAdmin';
}
swaiba,
Have you specified sort-weight should be added between DataObjectA and DataObjectB *before initializing*?
The module's _config.php should read;
SortWeightRegistry::decorate('DataObjectA','DataObjectB');
SortWeightRegistry::set_module_path(basename(dirname(__FILE__)));
I also believe I have an experimental version somewhere (will have to check when I return home) that I was working out some bugs on. I never committed this module as I still wasn't happy with the ability to tap into Complex Table Fields (core doesn't allow for an "onConstruct" callback of Objects, and the CTF doesn't provide any useful extension points). As a workaround it probably makes sense to use a SortableComplexTableField for displaying relations; but I wanted this module to be "plug-n-play" w/o having devs change anything. The 3.0 version of SilverStripe will feature a very nice grid to replace ComplexTableField/TableListField which I am sure will provide the best interface going forward. For 2.0 there's the DataObjectManager module which supports sortable -- and hopefully SortWeight as a more light-weight & SS-friendly alternative. Let me know if it works.
~ Brice
Hi Brice,
Thank you for getting back to me and yes I do already have the config line you have mentioned.
If it were a SortableComplexTableField then it would be great - then I could ensure it's use instead of relying of on the automatic replacement.
I understand that SS3 Datagrid will replace CTF (when it is stable) and also that the DOM has this functionality. However for this project I avoid using any large modules (only like to integrate small modules into it instead into the codebase) also since it's a big project it is likely I will continue with CTF for a while (as SS have indicated legacy will work so I assume CTF will become a module, just like the old time fields).
Thanks again for you help
Barry
- Previous 10 entries
- 1
- Page 22(current)