I'm very new to SS but I love it already. I'm writing quite a simple site and the most advanced topic I'm struggling with is a many-to-many relation between Projects and Resources that has an extra field called Priority. Any resource may be assigned to any number of projects with an integer priority.
In the CMS, I would like to be able to assign resources on the project page, using a checkbox, like with ManyManyComplexTableField but also be able to put in the priority in an edit box. API reference notes that ManyManyComplexTableField is deprecated in favor of GridField and I also saw people recommending it here on forums when I searched but I have no idea on how to use it.
Do you have a working example in one of your projects or maybe there is an existing addon with source code available to learn from? I would appreciate any tips on how to implement this functionality.
Anyone? It's the only thing keeping me from choosing SS for this project. Any working solution would do, not necessarily based on GridField, I'm okay updating database directly, I just need a pointer in a right direction on how can I edit many-to-many extra fields.
9 August 2012 at 5:15am
For now , there does not seem to be enough info about GridField . Not enough tutorials anyway , I only recommend SS3 for smaller projects & try use SS2.4.7 for more complex ones as there are more tutorilas & info for SS2.4.x .
First of all, thanks for replying. I considered using 2.4 since it seems better supported and I don't think I wrote any code that would be incompatible. Do you know of any convenient solutions for extra fields? I found [url=https://github.com/ajshort/silverstripe-itemsetfield]itemsetfield[/url] module (explanation for extra fields [url=https://groups.google.com/forum/?fromgroups#!topic/silverstripe-dev/kJB7BuChb8A%5B1-25%5D]here[/url]) but maybe there's a better built-in solution?
9 August 2012 at 5:30am
I had a look at the links you provided, they seem pretty good , I am not sure if there is a better solution ! .
I would love to see the code & maybe try to get it working in SS3 ! Upload the Module here & I see what i can do:)
24 January 2013 at 2:48pm
(Last edited: 24 January 2013 2:49pm),
I've had the same problem but since I'm not running the latest version, I'm not able to rely on Ingo solution.
Meanwhile I tried to add a component that implements GridField_ColumnProvider that looks like this
My main problem was that it's not possible (or not working?) to set a callback for the edit form for the detail view (which would enable me to add the extra fields to the detail form, which would be awesome). The callback is never called so... I've chosen a rather hacky way of doing things by simply allowing the user to click on the cell and enter a value. Then the value is updated through an ajax call.
And I just have an action on my modeladmin that does this
:-) so I realise this is not the standard way of doing things. But it would be super clean, I think, if it was possible to add a callback to the detail form to push the extra fields. This could be all automatically managed by model admin.