-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GridFieldEditableColumns does not support many_many through relationship's extra fields #371
Comments
Hi rasstislav, Can you please provide some details? |
Hi @GuySartorelli, Thank you for your response. Module supports only standard ManyManyList, but not ManyManyThroughList. You can see e.g. here https://github.com/symbiote/silverstripe-gridfieldextensions/blob/3.6.3/src/GridFieldEditableColumns.php#L253. |
Hi @rasstislav |
I am only using the GridFieldEditableColumns component and for Ranking field is displayed ReadonlyField. Versions: Code:
|
In the future please answer all questions asked in comments like that - it wasn't clear at all from your comments what about it wasn't working, so I had to boot up a fresh installation and run through a bunch of scenarios to find out for myself. In any case: It's an easy fix so I'll raise a PR momentarily. |
Fixed in #372 |
@kinglozzer Thanks :). @GuySartorelli It's better now, but it still doesn't work. Am I doing something wrong? Team
Supporter
TeamSupporter
|
My bad, I should’ve double-checked the fix was complete before merging. The field now shows, but it won’t load the value because values on the “through” record for many-many-through aren’t lazily loaded like they are for a regular many-many, they have to be accessed via the One approach for fixing this would be for us to say that when configuring editable columns, the array key has to be index e42be98..0dfbc58 100644
--- a/src/GridFieldEditableColumns.php
+++ b/src/GridFieldEditableColumns.php
@@ -252,10 +252,15 @@ class GridFieldEditableColumns extends GridFieldDataColumns implements
}
if (!$field && ($list instanceof ManyManyList || $list instanceof ManyManyThroughList)) {
- $extra = $list->getExtraFields();
+ $colName = $col;
+ if ($list instanceof ManyManyThroughList) {
+ // ManyManyThroughList join records need to be referenced with Join. prefix
+ $colName = preg_replace('/^join\./i', '', $colName);
+ }
- if ($extra && array_key_exists($col, $extra ?? [])) {
- $field = Injector::inst()->create($extra[$col], $col)->scaffoldFormField();
+ $extra = $list->getExtraFields();
+ if ($extra && array_key_exists($colName, $extra ?? [])) {
+ $field = Injector::inst()->create($extra[$colName], $col)->scaffoldFormField();
}
} Do you think that’s a good approach @GuySartorelli? |
Hmm. This was working for me locally but maybe I did something weird. I don't have time to look at this right now in any depth but we ideally shouldn't need to prefix the extrafield with the join name, as this would introduce a third syntax for handling many_many extrafields in gridfield (the main one being no prefix, and the second one being this weird nonsense). I'll reopen for now in any case since you're reporting that it's not resolved. |
Hi @GuySartorelli. Anything new in this issue? Thanks |
Nothing new, no. If there's something new there will be comments or a new PR :p This is an open issue, but that doesn't mean it's something that is being actively looked into. If you'd like to submit a pull request resolving the problem I'll gladly review it. In the meantime, this is in our backlog along with the other 42 issues on this repository, and all of the issues in the other core and supported modules. Hopefully that puts into perspective why this hasn't had any action since my last comment. |
Hello,
I have this issue.
This module does not support many_many through relationship joined on a separate DataObject (https://docs.silverstripe.org/en/4/developer_guides/model/relations/#many-many-through-relationship-joined-on-a-separate-dataobject).
PRs
The text was updated successfully, but these errors were encountered: