Comments (10)
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.
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.
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.
From stan.madueke on December 09, 2010 11:19:00
Sorry about that; I meant extra=0
, obviously :)
from django-dynamic-formset.
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.
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.
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.
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.
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.
Is there any solution for this issue exist now ?
from django-dynamic-formset.
Related Issues (20)
- delete link doesn't show and formCount is NaN HOT 4
- Uncaught ReferenceError: deleteButtonHTML is not defined
- No remove button and add won't add form HOT 3
- Simlutaneous deletion and creation not working HOT 8
- I have installed django_dynamic_formsets but it says the module not installed dynamic_formsets. I'm using windows 10 with python version 3.8.5.
- Limit minimum and maximum of formsets
- Nested formsets HOT 1
- Demo package download link is down
- Is it possible to include html inside addText or deleteText? HOT 4
- nothing
- deleteContainerClass does not seem to be working
- Only rows specified in 'extra' are saved and rows above 'extra' do not have default values
- deleteContainerClass not working properly HOT 1
- how to use onKeyup for django formset input fields
- delete button shows up only once in django formset that is created with queryset to edit
- Clicking on add row in update mode displays foreign keys even if label is none. HOT 1
- Input field id show NaN instead of increased number even with prefix set HOT 6
- does not seem to work with file fields HOT 1
- Deleting instance not working when hideLastAddForm is true HOT 1
- Unsetting and resetting the current formset
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-dynamic-formset.