Hi,

Your module is great but i think that we should be able to display column &/or row labels when we are in View mode (not only when we edit the node).

Hope this may help.

CommentFileSizeAuthor
#12 matrix_bug_after_columns_alter.png286.13 KBexintaexi

Comments

aaron1234nz’s picture

Thanks for pointing this out. I only took over being maintainer of this module the other day so I'm still getting my head around the way things work in this module. I've worked out how to fix this now.

aaron1234nz’s picture

Status: Active » Fixed
chipway’s picture

Hi,

Thank you.

i don't see a dev version of februay 6 on http://drupal.org/project/Modules/date (it displays february 3).

is it the updated dev version ?

Thanks

chipway’s picture

Hi,

Thank you. I found the d6 dev version, but now i have the following issue :

i can create a matrix field = ok.

i do no see the matrix field either in create content nor in edit.

i do not see what is it about.

Thank you

aaron1234nz’s picture

Status: Fixed » Postponed (maintainer needs more info)

the Drupal.org script that packages up -dev versions runs every 12 hours, so it will often take a while for the new version to be downloadable.

Your issue is a strange one. Things work fine for me on my box. Just out of interest, what operating system are you running?

chipway’s picture

Hi,

i tried a lot of thing (desactivate, remove matrix folder, upload new folder, ...).
i found why i got the issue "i do no see the matrix field either in create content nor in edit." It was when having no row label !

But i think that we should be able to set row label OR column lables OR both.

Now, i have a annoying behaveour :
i setup row labels + column labels, but all is upside down and left/right when i View the node :
- vertical order of row is inverted
- column order is inverted
- i can't see the row labels or column labels

chipway’s picture

Hi,

i tried on another server, with 10 rows and 4 columns. Findings :

1) When all cells of my first rows are filled;
- rows' and columns' labels are displayed in edit and view
- order is right

But, i would like not to see row label for empty rows.

2) When a cell is empty in my filled rows (ex: second column of second row, only 2 rows filled). EDIT is ok, but not View;
- all is inverted up/down and left/right, so my row 1 is now on row 9 and my row 2 is now on row 8 (nothing on row 10 ??)
- rows' and columns' labels are in the right order
- content in inverted column 1 in 4, column 2 in 3, column 3 in 2, column 4 in 1

3) now, i fill the previous empty cell. EDIT is ok, but not View;
- row 1 is on row 10 (??)
- row 2 is on row 9
- all content is inverted left/right

Hope this help.

chipway’s picture

Hi,

i tried on another server, with 10 rows and 4 columns. Findings :

1) When all cells of my first rows are filled;
- rows' and columns' labels are displayed in edit and view
- order is right

But, i would like not to see row label for empty rows.

2) When a cell is empty in my filled rows (ex: second column of second row, only 2 rows filled). EDIT is ok, but not View;
- all is inverted up/down and left/right, so my row 1 is now on row 9 and my row 2 is now on row 8 (nothing on row 10 ??)
- rows' and columns' labels are in the right order
- content in inverted column 1 in 4, column 2 in 3, column 3 in 2, column 4 in 1

3) now, i fill the previous empty cell. EDIT is ok, but not View;
- row 1 is on row 10 (??)
- row 2 is on row 9
- all content is inverted left/right

Hope this help.

aaron1234nz’s picture

I'm sorry, I cant replicate your issues. The module does not invert my data in any way. I've made some changes which may help. Try the new version.

exintaexi’s picture

I can second cwdrup's bug. I reproduced that bug in a test/demo site I have.

Matrix field:
1) Vanishes the last row
2) Inverts the data horizontally and vertically

While it worked normally, I tried to EDIT a matrix field. I created a field, created some data (2-3 entries) and then I inserted a column somewhere in the middle and appended a column at the end to check out if the field moved the values accordingly.

In edit mode I can see that the values were not moved accordingly (but no data loss) but in view mode it started displaying like I described.

I should also notice that the field inverts the data even in new content entries since I changed the columns.

aaron1234nz’s picture

hmmm interesting.

I'm not sure I follow all of your steps. Are you able to post step-by-step instruction on how to replicate his bug (upload a csv file with data and screenshots would be good). Once I can replicate it, I should be able to fix it.

exintaexi’s picture

StatusFileSize
new286.13 KB

Sure thing,

1) I create a new content type of "Test Matrix Stats" (test_matrix_stats).
2) I add a custom field "Test Matrix" (field_testmatrix) of Matrix Field kind.
3) I add columns "Goals, Attempts, Yellow Cards, Red Cards, Offsides, Substitutes" and rows "Home Team, Away Team".
4) I add 2 entries of "Test Matrix Stats" with values for my matrix field 1 to 12 for the first one and values 13 to 24 for the second one.

Everything works fine!

5) I edit the columns of my field to "Goals, Attempts, HEADERS, Yellow Cards, Red Cards, Offsides, Substitutes, FOULS COMMITED"

I check my site and matrix field has shifted all values to the current 6 first columns, quite expected!

6) I update one entry and add values "a, b, c, d" to the empty matrix fields.

Content gets messed up! But in edit mode, content still displays correct!

It actually vanishes the last row but the first row is displayed with the second row's title.
I'm sorry, I just realized you'd probably preferred a multi-row demo to examine the bug's pattern, but I guess you'll figure this out easily since it just appears on view mode.

Maybe I'll check the code a bit later, I haven't much experience in php and even less in drupal, but I think I'll be able to just "read it".

I'm attaching a detailed image with screens.

aaron1234nz’s picture

Thank you very much for documenting this issue so well, unfortunately, oddly enough my system will not replicate your error. I've even tried a fresh drupal installation. I've made some changes to make the display work better, hopefully this will help fix this issue. Let me know how this version goes.

jasonqi’s picture

I believe the problem is here line 93 to 126 of matrix.module (Feb 22,2009).
***Sorry, when I look into the matrix.module March 13,2009, the code below on line 84 to 117 ***

the statement of "case 'update' " looks strange, one to delete something and one goes with 'insert' .

The first "case 'update' " should be "case 'delete'" and also, what the "DELETE FROM ... " to delete?
The second "case 'update' " expects its own update code, should not share with 'insert'.

Just my 2 cents.

Jason

switch ($op) {
    case 'load':
      $result = db_query("SELECT value, row, col FROM {node_field_matrix_data} WHERE vid = %d AND field_name = '%s'", $node->vid, $field['field_name']);
      $values = array();
      while ($data = db_fetch_object($result)) {
        $values['data'][$data->row][$data->col] = $data->value;
      }
      $values['rows_header'] = $rows;
      $values['cols_header'] = $cols;
      $additions = array($field['field_name'] => $values);
      return $additions;
    case 'update':
       db_query("DELETE FROM {node_field_matrix_data} WHERE vid = %d and field_name= '%s'", $node->vid, $field['field_name']);
    case 'update':
    case 'insert':
      $i=0; 
      foreach ($rows as $row) {
        if ($row) {
          $j=0;
          foreach ($cols as $col) {
            if ($col) {
              db_query("INSERT INTO {node_field_matrix_data} (nid, vid, field_name, row, col, value)
                        VALUES (%d, %d, '%s', %d, %d, '%s')",
                        $node->nid, $node->vid, $field['field_name'], $i, $j, $items[0][$i][$j]
                      );
              $j++;
            }
          }
          $i++;
        }
      }
      break;
  }
}

aaron1234nz’s picture

My code is as it should be.

The first update will remove all the data from the table. As I do not have break; statement after this update, the switch statement will continue on and trigger the second update, which will insert fresh data.

I have a feeling that the ksort thing you proposed on the other issue should be the fix here too!

jasonqi’s picture

Sorry, I did not realize there is no "break".

"delete + insert = update" is a nice idea here, however, I still have a question (may not related to this issue)

There is no "delete" op, does it mean the CCK(content.module) will handle the deleting thing?

exintaexi’s picture

aaron1234nz,

I had a few minutes to check out version 1.4 and it seems that you successfully fixed the problem with the inverted data! I don't know what it was, I'll check it out again when I have some free time, but with a quick look everything runs smoothly now!

Thank you very much for your work! It's appreciated :-)

aaron1234nz’s picture

Status: Postponed (maintainer needs more info) » Fixed

Thats great news!

jasonqi suggested that the issue was that the data was being represented in key-order. On my machine the keys were always in numeric order, but on other systems the keys were in order entered. I assume this must be a difference between PHP versions. Anyway, explicitly sorting the data by key fixed the problem.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.