Each workflow allows the user to assign a weight to the state name. It looks currently like this weight is only used when administering the workflow itself, and not when the states are displayed in the node edit form or in the workflow tab of the node edit mode.
Workflow states in the node edit context are currently sorted by array key which corresponds to the unique state id in the database. This normally isn't a problem as workflow designers usually create their states in the order they intend on using them. A user may have a situation where a new state is added to a workflow and preceeds (in weight) others which have already been created. In this case it will be assigned a state id in the database greater than existing states. Ordering by state id will make this state display near the end of the list of valid states to select from instead of the top where it should be if the states were ordered by weight.
Sorting by weight is important as it provides a way for the workflow designer to ensure the default state for newly created nodes is a valid state with the lowest weight regardless of when the state was added to the workflow.
Weight should be respected when displaying allowed states for nodes. The attached patch removes the array sorting by key(state id) and ensures proper sorting by weight in the workflow_field_choices() function.
| Comment | File | Size | Author |
|---|---|---|---|
| order_by_weight.patch | 2.61 KB | dayre |
Comments
Comment #1
JacobSingh commentedThis is a duplicate of http://drupal.org/node/116733.
Please review the patch there and submit yours if you feel it improves upon it somehow (with an explanation of why).
Best,
J