On 06/07/2015 02:18 AM, Shai Berger wrote:
> Semi-devil's-advocate suggestion: Replace the management form with a 
> management field, a hidden field with
>  
>       name = "__manage__%s" % (formsetname) 
> 
> and 
> 
>       value="x"
> 
> Then instead of taking the number of forms from a field on a management form, 
> we can just take the accumulated length of the management field (which would 
> be 
> returned as an array). This also offers a better solution to the checkboxes-
> only-form problem, I think.

I think this is a promising germ of an idea for a better approach to
formsets. It would be tricky to make it backwards-compatible (and it
simply can't be backwards-compatible in terms of markup, meaning it
would break all the dynamic-formset JS out in the wild).

> Do we use the management form for anything other than counting forms in the 
> formset?

We do - we also use it for counting "initial" vs "extra" (or new) forms.
However, your idea could easily be extended to cover that as well.

We also use it for communicating min-num and max-num to the client side,
for use by dynamic-formset JS. (Such JS usually also relies on the
total-form-count and initial-form-count values).

Carl

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/5575E8AC.50200%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to