diff --git a/src/unfold/static/admin/js/inlines.js b/src/unfold/static/admin/js/inlines.js index 2f3dbb88c..45da8a9f5 100644 --- a/src/unfold/static/admin/js/inlines.js +++ b/src/unfold/static/admin/js/inlines.js @@ -91,6 +91,10 @@ const addInlineClickHandler = function (e) { e.preventDefault(); const template = $("#" + options.prefix + "-empty"); + // Check if template exists (has_add_permission check) + if (template.length === 0) { + return; + } const row = template.clone(true); row .removeClass(options.emptyCssClass) @@ -284,8 +288,12 @@ // Show the add button if allowed to add more items. // Note that max_num = None translates to a blank string. + // Check if template exists (has_add_permission check) + const template = $("#" + options.prefix + "-empty"); + const hasAddPermission = template.length > 0; const showAddButton = - maxForms.val() === "" || maxForms.val() - totalForms.val() > 0; + hasAddPermission && + (maxForms.val() === "" || maxForms.val() - totalForms.val() > 0); if ($this.length && showAddButton) { addButton.parent().show(); } else { diff --git a/src/unfold/templates/unfold/helpers/edit_inline/tabular_row.html b/src/unfold/templates/unfold/helpers/edit_inline/tabular_row.html index 1d9547c8e..c618567d8 100644 --- a/src/unfold/templates/unfold/helpers/edit_inline/tabular_row.html +++ b/src/unfold/templates/unfold/helpers/edit_inline/tabular_row.html @@ -1,4 +1,4 @@ - + {% spaceless %} {% for fieldset in inline_admin_form %} {% for line in fieldset %}