Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
calculating the duration worked out using the computed field
I have requirement to
1.sum up all the durations in a work experience field collection in resume,
help me please pl.
2. Calculate the duration from the oldest start date to Date Now()
have look at screen shot
help please
Comment | File | Size | Author |
---|---|---|---|
resume.png | 62.95 KB | kaizerking |
Comments
Comment #1
astanley86 CreditAttribution: astanley86 commentedDid you figure out how to do this? I am trying to do the exact same thing!
Thanks.
Comment #2
kaizerking CreditAttribution: kaizerking commentedthere is no existing module, and you need to develop a custom module for this, it is really tough job i didn't use computed field module, this module doesn't work with fields 'attached' to field collection fields
Comment #3
astanley86 CreditAttribution: astanley86 commentedCan you share your custom module? I'm discovering it is more complicated that I'm capable of doing with my limited knowledge of programming.
Comment #4
jlsevillano CreditAttribution: jlsevillano commentedDid you resolve the problem? I have the same problem :(
Comment #5
david.qdoscc CreditAttribution: david.qdoscc commentedThis should work in a computed field to sum field collection values:
$sum = 0;
$wrapper = entity_metadata_wrapper($entity_type, $entity);
foreach($wrapper->field_YOURFIELDCOLLECTION as $collection) {
$sum += $collection->field_YOURSUBFIELD->value();
}
$entity_field[0]['value'] = $sum;
Comment #6
James Feng CreditAttribution: James Feng commentedqdoscc's code is good,Thank you。