ensure weights in integer weight select #800
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this Pull Request do?
Fixes an issue where the integer weight selector can be made impossible to correctly re-weight things using the select menus.
The issue can be seen if you take the steps under "How should this be tested" below.
You'll see (in the current codebase) that performing the steps in the test case makes it so that you cannot change the weight values of the child members using the select fields.
This is happening because those select menus are populated by first populating options for each current weight value for each member, then if any weights are currently an empty string, running through and adding a number for each row, starting from 1.
It breaks because of two things:
This is kind of compounded by the fact that if you do indeed allow someone to modify weights as part of the Repository Item creation form, they can put any number they'd like in there, so once you attempt reordering, there's no guarantee you'll have numbers in the select field you can use to reorder weights.
What's new?
The form now creates weight select fields that contain all existing values as options, plus one guaranteed option for each possible row number.
How should this be tested?
Additional Notes:
This might not be the best solution to the issue ... weight fields in forms use the 'number' type form element, so would it be better to do so here as well? That would also ensure that any arbitrary number is still valid, works with
#default_value
, and doesn't create a massive select field.Interested parties
@Islandora/8-x-committers