Calculated fields don't work inside multigroups because there is no way for the PHP to know which of the multis it should be targeting. That is, in
<input name="group_foo[N][field_bar][value]"
there's no way for the PHP to retrieve the value of N.
However, if there were a hidden field with javascript which went into the DOM and retrieved N and put it into the field's value, then a calculation on that field would have the value available, and could proceed from there, with the capability to read or alter the values of other fields in the group.
I'm not strong enough in drupal to do this myself, but I think it could work.
Is this good enough for someone to help me implement it? There are pretty regular posts from people who could use this capability.
Comments
Comment #1
markus_petrux commentedAre you trying this with a contrib or custom module?
Are the calculations performed on the server or client?
Here's an issue on the Computed fields queue where I posted how to perform calculations on multigroup: #349548: Conditional result for hook_content_is_empty()
Comment #2
Neil_in_Chicago commented((disclaimer: I'm new to drupal, and don't know my way around, or the jargon, very well.))
I think this would be a contrib. Javascript executes on the client, PHP on the host.
What I'm envisioning is a field as one of the fields in a multigroup. It's non-display, and onLoad, or something like that, it triggers a javascript which looks at the DOM position and gives the field the value of its group number/subscript ("N" in my example). Then, when the page is saved, the drupal computed field script attached to the field executes. Since the PHP has the necessary subscript it can do its stuff on that specific subgroup, knowing which one it is.
Researching this, I did see the references to the "empty" problem. With this hack, the calculated field PHP can specificly test
$group_foo[N][field_something][value], because it has N.if(!isempty($group_foo[N][field_something][value])) { }. (Yeah, I probably have the reference wrong, but I hope the idea is clear.)Comment #3
drupalnesia commentedWhat is the status of this issue? Should this issue fixed on CCK or Computed Field side?
I got this message when I try to add a computed field to multigroup:
Comment #4
karens commentedAny work on this belongs in the computed field queue. Unless the computed field maintainer thinks there is a need for some change on this side.