wagtail
wagtail copied to clipboard
Fix the order of InlinePanel with min_num argument
Fixes #9391
this issue because the the initial forms not have value
attribute. if "min_num" is any number and after that another item added,
this item become first despite the number of "min_num". but if any action occurs to any item of initial forms for example the item moved up or down , in this case the item become has attribute, and this issue not exist in this case.
After | Before |
---|---|
another way to set "value" attribute to the initial forms , but in the client , and solve this issue in the same idea, in the constructor of class "InlinePanel" , just add this code :
for (let i = 0; i < this.formCount; i++) {
const newChildPrefix = this.opts.emptyChildFormPrefix.replace(
/__prefix__/g,
i,
);
if ($('#id_' + newChildPrefix + '-ORDER').attr("value") !== undefined) {
break
}
$('#id_' + newChildPrefix + '-ORDER')
.val(i + 1);
}