Added options addWrap, deleteWrap, addInsert and formInsert #80
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.
These changes introduce four new options, with docs and tests:
addWrap
anddeleteWrap
let you wrap the add and delete buttons in an element (or multiple nested elements - value is passed to jQuery's.wrap
) to make it easier to style the buttons and manage form layout.addInsert
is a callback to manage where the add button is inserted. This can be used to put the add button at the top of the forms, or outside the formset altogether.My particular use case is that I wanted to style the forms and buttons using CSS
li:nth-child(even)
, and my hiddenformTemplate
fell between old and new forms, so was knocking the order out; this allows me to put the add button above the hiddenformTemplate
, rather than at the bottom.formInsert
is a callback to manage where and how the form is added. I've used it with jQuery's.slideDown
, but would also be used with theaddInsert
callback to add forms at the top of the formset (see test) or from an add button outside the formset.Please note though that I only extended the current tests, so they only cover divs, not tables.
I also changed the indentation for formset options in usage.rst - github wasn't displaying anything after the first
versionadded
.