django-material-admin
django-material-admin copied to clipboard
Input select-accross is not in action form
This input is not inside the changelist-form so when you click on select all items in the list and then select an action, the action is only applying to the 10 items displayed on the page.
<input type="hidden" name="select_across" value="1" class="select-across">
Hi, any workaround for this?
I did something kind of hacky to fix it. I overrode admin/base_site.html and in the footer section I added my own javascript to fix it.
$(document).on('click', '.question', function () {
$("#changelist-form").append('<input type="hidden" name="select_across" value="1" class="select-across">');
let clearButton = document.querySelectorAll('.card-content span.clear')[0];
clearButton.style = "display: inline;"
})
$(document).on('click', '.card-content span.clear a', function () {
let clearButton = document.querySelectorAll('.card-content span.clear')[0];
clearButton.style = "display: none;"
})
You can also just edit/override the template actions.html and add "display: none;" to the proper span tags. No JS required. Page should initially load with display set to none anyway but seems it was forgotten.
Also for input select_across. you can also just add the form attribute and give it the value "changelist-form" This will pass select_across into your request.POST