Closed (fixed)
Project:
Matrix field
Version:
6.x-1.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
1 Feb 2007 at 16:08 UTC
Updated:
1 May 2011 at 01:49 UTC
Hello,
I'm trying to use your module with the CCK Computed module to create a timesheet application. However, when I run the code
$node_field[0]['value'] = $field->field_weekly[1][2]['value'] - $field->field_weekly[1][1]['value'];
in the CCK Computer field, it does not store a value in the database or display the value after the page is saved. The same code did work with a simple integer field type.
Comments
Comment #1
mh86 commentedI've never tried this and I'm not familiar with the cck computed field module, but you have to address the values of the matrix field without the 'value' at the end, e.g. it's only $field->field_weekly[1][2]
Hope this helps you!
Comment #2
hsfdrupal commentedHm, I can't get this to work either.
Shouldn't the code be $node->field_weekly[1][2]? What is $field?
Comment #3
mira2 commentedI was just wondering if you could work out these 2 together? I need to create a timesheet type of field where hours entered for different tasks could be computed and outputed on the page for users' consultation. Any success yet?
Comment #4
reubenavery commentedI can confirm that Matrix Field does not work with with Computed Fields. I am not sure why, but I have confirmed that the $node object passed to the computation function for a field does not include the node's matrix field. I had to end up writing a sql query to get at the matrix field's values.
Comment #5
Rosamunda commentedSuscribing.
Comment #6
aaron1234nz commentedI would be very surprised if this module could be used with computed fields. The architecture doesn't lend itself that way. I'm marking this as a "won't fix" because I don't think its possible, at least not without masses of work.
Comment #7
ericatkins commentedHow would one calculate the integers in the first column of a Matrix? Would that be done in the Content Type with some other kind of CCK object? Or would that be done in the body with some PHP code? And could that value be stored in the database and referenced later with Views?
I'm at a loss on how to do the questions I've asked above.
Comment #8
aaron1234nz commentedI would suggest using php code to do this.
I would start with this code. It will show you what you have to play with
I think (off the top of my head) that you want to use $node->yourfieldname[0]['data'][$i][$j] where $i is the row number and $j is the column number. To sum a column you would write something like
Note this is only psudo code and is not tested.
This data would not be available to views.
Note: I'm doing a bit of work on Matrix version 2 which will allow for select boxes, checkboxes, radio buttons, and textfields. Maybe I could calculations to this list too. I'll give it some thought
Comment #9
ericatkins commentedThanks aaron1234nz.
If you add a 'calculated value' feature to the 'Matrix Field' CCK type, you'll have to rename your module to CCK Spreadsheet.
That's what it would nearly be, a Spreadsheet.
Comment #10
aaron1234nz commentedI'm not quite going to go as far as turning this module into a spreadsheet. That would take a LOT more work. Have you seen this module? http://drupal.org/project/sheetnode it might be of use to you.
Comment #11
aaron1234nz commentedThis functionality is implemented (in a fairly basic form only) in version 2. Please open a new issue if you wish to discuss an aspect of this functionality.
Comment #13
Stomper commentedGlad to hear that some level of computation is supported. I too am seeking simple summation computation. The Sheetnode module you suggested may be overkill for my application.
Does the Matrixfield demonstration (link on project page http://sandbox.webtolife.org/) include this computed field feature?
Thanks