Giter VIP home page Giter VIP logo

Comments (10)

elo80ka avatar elo80ka commented on July 21, 2024 1

From m%[email protected] on December 09, 2010 17:41:51

"extra=0" may lead to an empty formset which cannot be operated by django-dynamic-formset plugin (it needs at least 1 form to clone). My initial data can be empty, and currently i need either manually extend it by an empty form if there is no initial data (if formset's extra equals 0) or use bound formset instead of unbound if there is initial data (assuming "extra=1"). The second way is a bit ugly though :)

Is it possible to distinguish extra forms in formset from "common" in JS side? If yes, it would be nice to have a parameter like "noExtra" there to always hide extra forms unless there is only one form, which is "extra".

from django-dynamic-formset.

elo80ka avatar elo80ka commented on July 21, 2024 1

From stan.madueke on December 10, 2010 07:03:00

If you're using Django 1.2, you don't need to create anything; formset.empty_form will give you an empty form instance. You can render this in your template, wrapped in a hidden container of your choice, and it should work just fine (please file a ticket if it doesn't).

And if you aren't using Django 1.2...well, why the heck not? :D

from django-dynamic-formset.

elo80ka avatar elo80ka commented on July 21, 2024

From stan.madueke on December 09, 2010 11:08:12

I'm not sure if I understand you completely, but won't empty=0 solve your problem?

from django-dynamic-formset.

elo80ka avatar elo80ka commented on July 21, 2024

From stan.madueke on December 09, 2010 11:19:00

Sorry about that; I meant extra=0, obviously :)

from django-dynamic-formset.

elo80ka avatar elo80ka commented on July 21, 2024

From stan.madueke on December 09, 2010 22:25:51

If you use extra=0, you'll need to set formTemplate to point to a hidden form -- take a look at the source for the form template example in the demo project, to see how this works.

from django-dynamic-formset.

elo80ka avatar elo80ka commented on July 21, 2024

From m%[email protected] on December 10, 2010 04:27:29

Doesn't seem good to me. I need to create an empty form and pass it to template from every django view function. "extra=0" does the same - renders an empty extra form, but automatically, it just need to be hidden on client side.

from django-dynamic-formset.

elo80ka avatar elo80ka commented on July 21, 2024

From carl.j.meyer on February 26, 2011 14:59:03

Have you actually tried using jquery.formset.js with an empty formset using extra=0 and formTemplate? It doesn't work for me, and looking at the code I can't see how it could possibly work: the entire chunk of code that includes the insertion of the Add button is protected by "if ($$.length)", which will be false if the formset has no forms.

from django-dynamic-formset.

elo80ka avatar elo80ka commented on July 21, 2024

From carl.j.meyer on February 26, 2011 15:05:40

Also, the API would need to be modified in order for this to work, because currently .formset() is called on the list of form elements. If it's called on an empty list of elements, it has no way to know where it should insert the Add link! So the API would need to change to passing in the parent container of the entire formset, or something like that.

from django-dynamic-formset.

elo80ka avatar elo80ka commented on July 21, 2024

From stan.madueke on April 29, 2011 10:43:50

@carl: not really. $(...).formset() doesn't need to be called on an actual form -- you can call it, for instance, on an empty DIV, in which case it (the DIV) provides an "anchor point". The "add another" link will be placed below this anchor point, and all cloned forms will appear between the anchor and the "add" link.
I've tweaked the RegExp so the plugin now works out-of-the-box with empty_form -- see the example in the demo project.

from django-dynamic-formset.

sandeepbalagopal09 avatar sandeepbalagopal09 commented on July 21, 2024

Is there any solution for this issue exist now ?

from django-dynamic-formset.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.