Using the latest snapshot
(http://drupalcode.org/project/weight.git/commit/2b111d5e80d88ef34fa8f864...)

When I change the weight using the "select" HTML element, in the view or in the edit node page and save the value is saved to the database.

Then the page is loaded with the rows in the weight order, but the select elements doesn't show the real weight values, instead, they show the last values used in that form, ordered by their value.

I mean, I have two browsers showing the view page, I change the order of weights (with the select element of each row) in browser A, then reload the browser B, this one (B) shows the rows in the real weight order, and altough the weight select elements are shown in weight order, they show the last value set in browser B.

It's worse editing an individual node, no matter which weight value it has, the weight select element value's is the last one used in that form, so if I open the edit node page, don't change anything, and save, the node weight can be changed.

This is my view export:

$view = new view;
$view->name = 'asdf_weight';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'asdf weight';
$view->core = 7;
$view->api_version = '3.0-alpha1';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'asdf';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '';
$handler->display->display_options['style_plugin'] = 'weight';
$handler->display->display_options['style_options']['columns'] = array(
  'title' => 'title',
  'field_asdf' => 'field_asdf',
  'weight' => 'weight',
);
$handler->display->display_options['style_options']['default'] = 'weight';
$handler->display->display_options['style_options']['info'] = array(
  'title' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
  ),
  'field_asdf' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
  ),
  'weight' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
  ),
);
$handler->display->display_options['style_options']['override'] = 1;
$handler->display->display_options['style_options']['sticky'] = 0;
$handler->display->display_options['style_options']['empty_table'] = 0;
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
$handler->display->display_options['fields']['title']['link_to_node'] = 1;
/* Field: Content: asdf */
$handler->display->display_options['fields']['field_asdf']['id'] = 'field_asdf';
$handler->display->display_options['fields']['field_asdf']['table'] = 'field_data_field_asdf';
$handler->display->display_options['fields']['field_asdf']['field'] = 'field_asdf';
$handler->display->display_options['fields']['field_asdf']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_asdf']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_asdf']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_asdf']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_asdf']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['field_asdf']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['field_asdf']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_asdf']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_asdf']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_asdf']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_asdf']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_asdf']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_asdf']['element_label_colon'] = 1;
$handler->display->display_options['fields']['field_asdf']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_asdf']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_asdf']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_asdf']['hide_alter_empty'] = 0;
$handler->display->display_options['fields']['field_asdf']['settings'] = array(
  'thousand_separator' => ' ',
  'prefix_suffix' => 1,
);
$handler->display->display_options['fields']['field_asdf']['field_api_classes'] = 0;
/* Field: Weight: Weight */
$handler->display->display_options['fields']['weight']['id'] = 'weight';
$handler->display->display_options['fields']['weight']['table'] = 'node_weight';
$handler->display->display_options['fields']['weight']['field'] = 'weight';
$handler->display->display_options['fields']['weight']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['weight']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['weight']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['weight']['alter']['external'] = 0;
$handler->display->display_options['fields']['weight']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['weight']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['weight']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['weight']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['weight']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['weight']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['weight']['alter']['trim'] = 0;
$handler->display->display_options['fields']['weight']['alter']['html'] = 0;
$handler->display->display_options['fields']['weight']['element_label_colon'] = 1;
$handler->display->display_options['fields']['weight']['element_default_classes'] = 1;
$handler->display->display_options['fields']['weight']['hide_empty'] = 0;
$handler->display->display_options['fields']['weight']['empty_zero'] = 0;
$handler->display->display_options['fields']['weight']['hide_alter_empty'] = 0;
$handler->display->display_options['fields']['weight']['format_plural'] = 0;
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 0;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'asdf' => 'asdf',
);

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'asdf2';
$translatables['asdf_weight'] = array(
  t('Master'),
  t('asdf'),
  t('more'),
  t('Apply'),
  t('Reset'),
  t('Sort by'),
  t('Asc'),
  t('Desc'),
  t('Items per page'),
  t('- All -'),
  t('Offset'),
  t('Weight'),
  t('.'),
  t(','),
  t('Page'),
);

Comments

Anonymous’s picture

Title: The weight changes but is not showed » The weight changes but is not shown

Ups! fixing typo in the title

davisben’s picture

Category: bug » support

Hi ArtedeMagia.com,
It looks like your view is missing a sort field. To have the node display in weight order, you need to sort by weight, ascending. I have exported a simple view for you to use as a base for creating yours. Let me know if you need any more help getting this setup.

$view = new view;
$view->name = 'weight_changer';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Weight Changer';
$view->core = 7;
$view->api_version = '3.0-alpha1';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Weight Changer';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'weight';
$handler->display->display_options['style_options']['columns'] = array(
'title' => 'title',
'weight' => 'weight',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
'title' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
),
'weight' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
),
);
$handler->display->display_options['style_options']['override'] = 1;
$handler->display->display_options['style_options']['sticky'] = 0;
$handler->display->display_options['style_options']['empty_table'] = 0;
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
$handler->display->display_options['fields']['title']['link_to_node'] = 1;
/* Field: Weight: Weight */
$handler->display->display_options['fields']['weight']['id'] = 'weight';
$handler->display->display_options['fields']['weight']['table'] = 'node_weight';
$handler->display->display_options['fields']['weight']['field'] = 'weight';
$handler->display->display_options['fields']['weight']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['weight']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['weight']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['weight']['alter']['external'] = 0;
$handler->display->display_options['fields']['weight']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['weight']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['weight']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['weight']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['weight']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['weight']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['weight']['alter']['trim'] = 0;
$handler->display->display_options['fields']['weight']['alter']['html'] = 0;
$handler->display->display_options['fields']['weight']['element_label_colon'] = 1;
$handler->display->display_options['fields']['weight']['element_default_classes'] = 1;
$handler->display->display_options['fields']['weight']['hide_empty'] = 0;
$handler->display->display_options['fields']['weight']['empty_zero'] = 0;
$handler->display->display_options['fields']['weight']['hide_alter_empty'] = 0;
$handler->display->display_options['fields']['weight']['format_plural'] = 0;
/* Sort criterion: Weight: Weight */
$handler->display->display_options['sorts']['weight']['id'] = 'weight';
$handler->display->display_options['sorts']['weight']['table'] = 'node_weight';
$handler->display->display_options['sorts']['weight']['field'] = 'weight';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 0;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'weight-changer';

Anonymous’s picture

OK, thanks.

This is what I found is happening, with a view like yours it works OK, nice :) ! ...but when I add another field, plus the title and the weight, by example an image field, the view messes up and comes back that strange behaviour I was trying to describe.

I'm I doing something wrong?

Should I mark this issue as fixed and open a new one for this error?

Many thanks!

davisben’s picture

I changed the submit function to use node_save instead of just updating the stick column in the database, so now the weight changes will be reflected on the node edit form.

I made a small edit to the weight changer table to fix a bug allowing extra columns to show up, but I don't think that was related to any of your issues. I think your issue is related to sorting, as I'm not able to reproduce any errors with the ordering of nodes in the weight changer. The only sort field should be weight ascending, and in the weight changer style settings, the default sort should be none. Let me know if that helps.

Anonymous’s picture

Status: Active » Fixed

Wow! That's great! You are very fast! :)

Now it works like a charm.

I guess you were right about my sorting issues...

Many thanks!

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

fixing typo