Giter VIP home page Giter VIP logo

django-dynamic-formset's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-dynamic-formset's Issues

Clicking the 'add another' link on a page with multiple formsets reveals the 'remove' link for ALL formsets.

From [email protected] on April 05, 2010 15:19:46

What steps will reproduce the problem? 1. Have at least 2 formsets on one page that initially have 1 form in each.
2. Initialize the formsets as per the django-dynamic-formset documentation.
3. Click on the 'add another' link. What is the expected output? What do you see instead? The 'remove' link will ONLY be added to the forms in the formset where the
'add another' link is located. What version of the product are you using? On what operating system? 1.1, tested in safari + firefox Please provide any additional information below. My fix:
change line 93 of jquery.formset.js from:

if (formCount > 1) { $('a.' + options.deleteCssClass).show(); }

to:

if (formCount > 1) { $('.' + options.formCssClass + ' a.' +
options.deleteCssClass).show(); }

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=8

More predictable way of placing Delete buttons for tables

From [email protected] on October 20, 2011 23:22:52

What steps will reproduce the problem? 1. Add some additional elements (for instance, additional buttons) inside last column of table formset.
2. Even though I placed hidden input (delete control) before all other elements, visible Delete button rendered after all other elements in a cell. What is the expected output? What do you see instead? Delete button rendered in place of hidden input (delete control). Please provide any additional information below. Here is a simple path.
Instead this:
row.children(':last').append('' + options.deleteText + '');
Use this:
row.find('input:hidden[id $= "-DELETE"]').after('' + options.deleteText + '');

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=39

Remove <label> element

From vruiz2.0 on August 03, 2010 21:17:21

When you render a form directly in a template, the plugin doesn't remove the element for delete. For example:

{% for form in formset %}

{{ form }}

{% endfor %}

This way adds a element for delete element. It can be solved adding a simple line near line 90:

$$.each(function(i) {

var row = $(this),

    del = row.find('input:checkbox[id $= "-DELETE"]');

if (del.length) {

    // If you specify "can_delete = True" when creating an inline formset,

    // Django adds a checkbox to each form in the formset.

    // Replace the default checkbox with a hidden field:

    del.before('<input type="hidden" name="' + del.attr('name') +'" id="' + del.attr('id') +'" />');

    del.remove();

}

row.find('label[for $= "-DELETE"]').parent().remove();

if (hasChildElements(row)) {

    insertDeleteLink(row);

    row.addClass(options.formCssClass);

    applyExtraClasses(row, i);

}

});

It's a possible solution, but it isn't the best :)

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=12

Some improvements

From [email protected] on January 22, 2010 22:09:23

I have added a couple things to the plugin that I thought I should share.

  1. No delete link button if there is a checkbox, I see Nick did it a bit
    differently but ideally I think the delete link should stay and the checkbox
    should go and then use Nick's idea, but this works for me for now.
  2. Rows alternate is using the admin or cycle row1 row2 classes
  3. The clone uses the last row as apposed to the first row. This assumes you
    have extra >= 1 but work better as it does not copy extra stuff like the
    delete checkbox, or filename info from files.

Patch is attached.

Attachment: jquery.formset.js.patch

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=5

Multpile Inline Formset error

From [email protected] on April 19, 2011 04:09:10

What steps will reproduce the problem? 1. Create a ModelForm add two or more InlineFormsets
2. In page add more than one of each inlineformset
3. Submit form What is the expected output? What do you see instead? Expected output: form + multiple formsets would be added to the database
Result: Only the first of each additional inlineformset is added to the db What version of the product are you using? On what operating system? 1.2 Please provide any additional information below. I can get all the inlineformset data into the db if and only if I add all the inlineformsets plus an additional one, then delete the additional inlineformset this is the only work around.

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=27

Working with django-uni-form

From brianna.laugher on August 11, 2010 05:21:41

Hi,

This is pretty kick-ass, thanks for making it available.
I am also using django-uni-form which makes it easy to render forms in divs. There is only a small change needed to jquery.formset.js to make them work well together.

change line
$(row).find('input,select,textarea,label').each(function() {
to
$(row).find('input,select,textarea,label,div').each(function() {

then in my template, my javascript function is:

<script type="text/javascript">
      $(function() {
           $('#feedbackForms .singleForm').formset();
       })
</script>

then later in my template, my layout is thus:


{{ feedbackforms.management_form }}
{% for feedbackform in feedbackforms.forms %}

{{ feedbackform|as_uni_form }}

{% endfor %}

Then it all works perfectly. Just thought I would add this in case anyone else is using them together.

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=13

inlineformset causing 'NaN' indexing on new forms added

From [email protected] on June 03, 2012 17:22:10

What steps will reproduce the problem? 1. View:

@login_required
def newactors(request,matrixID):
mID = int(matrixID)
matrix = get_object_or_404(ThreatMatrix,pk=mID)
if not matrix.user_is_authorized(request.user):
raise Http404
else:
if request.method == 'POST':
actorformset = ActorFormSet(request.POST, instance=matrix)
if actorformset.is_valid():
debug ("Formset is valid")
raise EBADBREAK # abort before save to inspect things
savedactors = actorformset.save()
# because we want to override threatMatrix if the user has changed it...
return HttpResponseRedirect('/newactors/%d' % mID)
else:
return render(request,'newactors.html',{'actorformset':actorformset})
else:
a = ActorFormSet(instance=matrix)
return render(request,'newactors.html',{'actorformset':a})

  1. Form:

class ActorForm(forms.ModelForm):
class Meta:
model=Actor
widgets = {
'name': forms.TextInput(attrs={'size': 40,}),
'desc': forms.TextInput(attrs={'size': 80,}),
}

ActorFormSet = inlineformset_factory(ThreatMatrix,Actor,form=ActorForm, can_delete=True, extra=0)

  1. Template:

{% extends "basetemplate.html" %}
{% load i18n %}
{% block head %}
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script src='/static/jquery.formset.min.js' type='text/javascript'></script>
<script type="text/javascript">
$(function() {
$('.actorform').formset({
prefix: '{{ formset.prefix }}'
});
})
</script>
{% endblock %}
{% block main %}

{% csrf_token %} {% for form in actorformset.forms %}
{{form.errors}} {{form.as_p}}
{% endfor %} {{ actorformset.management_form }}

{% endblock %}

  1. Add a blank form with 'f' and 'b' for name and desc, respectively at the end of 5 prepopulated forms. What is the expected output? What do you see instead? Expected output in the traceback (since EBADBREAK is raised) is

actor_set-6-name u'f'
actor_set-6-desc u'b'
actor_set-TOTAL_FORMS u'6'

Actual output is

actor_set-NaN-name u'f'
actor_set-NaN-desc u'b'
actor_set-TOTAL_FORMS u'5' What version of the product are you using? On what operating system? Trunk on Mac OSX 10.7.3 Please provide any additional information below.

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=45

Should not set button's val to ''

From [email protected] on October 10, 2011 09:46:43

What steps will reproduce the problem? 1. set the addText to something with a button, like this: "

"
2. load a page
3. click the add link What is the expected output? What do you see instead? Should see the remove button with text. Instead see a remove button with the value set to '' What version of the product are you using? On what operating system? Using v1.2 on Debian 6. Please provide any additional information below. I made a patch. Diff:
117a118,119

                } else if (elem.is('input:button')) {
                    ; // Do nothing;

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=37

reverse deleting forms cause Key Error

From [email protected] on June 16, 2011 01:55:18

What steps will reproduce the problem? 1. Create 2 model formsets:

ParentFormSet = modelformset_factory(Parent, extra=1, can_delete=True, max_num=2)
GuardianFormSet = modelformset_factory(Guardian, extra=1, can_delete=True, max_num=10)

  1. Then if I have one instance of Guardian Form, add empty second form and instantly delete first, and then the second, thus having no forms, and press submit. What is the expected output? What do you see instead? Expected: Deletion of Guardian from DB and return of success template
    Got instead: Key error

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/iep_admin/add_student/5/

Django Version: 1.3
Python Version: 2.7.1
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.flatpages',
'django.contrib.staticfiles',
'django.contrib.webdesign',
'grappelli',
'django.contrib.admin',
'django.contrib.admindocs',
'uni_form',
'pagination',
'south',
'django_coverage',
'smart_selects',
'ajax_filtered_fields',
'ckeditor',
'countries',
'accounts',
'about',
'addresses',
'phones',
'languages',
'races',
'schools',
'persons',
'parents',
'guardians',
'students',
'employee',
'reports',
'iepachieve_app',
'note',
'transitions',
'dajaxice',
'iep_admin',
'iep_panel',
'task',
'meeting']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'pagination.middleware.PaginationMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')

Traceback:
File "/home/ki/Envs/iepachieve/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response

  1.                     response = callback(request, _callback_args, *_callback_kwargs)
    
    File "/home/ki/code/iepachieve/apps/students/views.py" in add_student
  2.     guardian_formset = GuardianFormSet(request.POST, request.FILES, queryset=guardian_queryset, prefix='guardian')
    
    File "/home/ki/Envs/iepachieve/lib/python2.7/site-packages/django/forms/models.py" in init
  3.     super(BaseModelFormSet, self).**init**(**defaults)
    
    File "/home/ki/Envs/iepachieve/lib/python2.7/site-packages/django/forms/formsets.py" in init
  4.     self._construct_forms()
    
    File "/home/ki/Envs/iepachieve/lib/python2.7/site-packages/django/forms/formsets.py" in _construct_forms
  5.         self.forms.append(self._construct_form(i))
    
    File "/home/ki/Envs/iepachieve/lib/python2.7/site-packages/django/forms/models.py" in _construct_form
  6.         pk = self.data[pk_key]
    
    File "/home/ki/Envs/iepachieve/lib/python2.7/site-packages/django/utils/datastructures.py" in getitem
  7.         raise MultiValueDictKeyError("Key &#37;r not found in &#37;r" &#37; (key, self))
    

Exception Type: MultiValueDictKeyError at /iep_admin/add_student/5/
Exception Value: "Key 'guardian-0-id' not found in <QueryDict: {u'last_name': [u'Belvedersky'], u'classification': [u'ED'], u'grade': [u'2'], u'guardian-1-middle_name': [u''], u'parent-0-race': [u''], u'guardian-1-birth_date': [u'1983-07-06'], u'phone_numbers': [u'1152'], u'guardian-TOTAL_FORMS': [u'2'], u'first_name': [u'Appolon2'], u'parent-0-first_name': [u'Ki4'], u'middle_name': [u''], u'parent-0-language': [u''], u'guardian-INITIAL_FORMS': [u'1'], u'parent-0-last_name': [u'P'], u'csrfmiddlewaretoken': [u'b66057413251cd8b465fb72a6c87ce5a'], u'parent-0-id': [u'11'], u'parent-0-DELETE': [u''], u'parent-INITIAL_FORMS': [u'1'], u'parent-0-gender': [u'm'], u'parent-0-occupation': [u''], u'parent-MAX_NUM_FORMS': [u'2'], u'parent-0-middle_name': [u''], u'parent-0-birth_date': [u'1983-07-06'], u'guardian-1-occupation': [u''], u'guardian-1-last_name': [u'Last'], u'guardian-1-id': [u'17'], u'guardian-1-first_name': [u'Guadian7'], u'guardian-1-race': [u''], u'language': [u''], u'level': [u'2'], u'gender': [u'm'], u'guardian-1-gender': [u'm'], u'race': [u''], u'guardian-1-DELETE': [u'on'], u'parent-TOTAL_FORMS': [u'1'], u'birth_date': [u'2010-11-17'], u'guardian-1-language': [u''], u'guardian-MAX_NUM_FORMS': [u'10']}>"
**************** What version of the product are you using? On what operating system? Please provide any additional information below.

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=30

should copy initial values for hidden fields?

From [email protected] on September 03, 2010 21:05:19

I have a formset of forms that contains some hidden fields with inital data and i'd like those initial data to be copied when I add a new form using the plugin.

I'm attaching a patch to solve this by not removing the val() on hidden fields, but I think maybe there should be an option for this.

thanks for the plugin, it's really useful :)

bruno gola

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=15

Empty and not empty formsets

From m%[email protected] on December 09, 2010 19:52:27

In order to be able to edit empty formsets, I need to pass "extra=1" (which is default) parameter in the formset_factory function, or else the jQuery plugin is unable to clone forms.

But if the formset is not empty, I actually don't need any extra lines to be added. Unfortunately, django's formset_factory function doesn't understand "min_num" parameter (though it does understand "max_num"), and hence I always get an extra line in formsets which I almost always need to remove manyally, otherwise a formset can't be validated due to empty required fields in the extra line.

Is there any workaround for this situation? I looked through the docs but failed to find anything about the issue.

Thanks.

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=18

MAX_NUM_FORMS not working as intended

From [email protected] on December 26, 2011 08:05:51

What steps will reproduce the problem? 1. Create inlineformset_factory with max_num set
2. Go to page showing form
3. Add unlimited number of forms, limit not respect What is the expected output? What do you see instead? Number of forms on page should be limited by max_num. Instead it is ignored. What version of the product are you using? On what operating system? 1.3 Please provide any additional information below. I noticed that max_num isn't being respected. I found the issue to be:

maxForms = $('#id_' + options.prefix + '-MAX_NUM_FORMS'),

options.prefix does not work as intended. In my case it should be "result_set" so (id="id_result_set-MAX_NUM_FORMS"). Using the debugger in Safari I discovered that options.prefix was not correct, it was empty (leading to "id_MAX_NUM_FORMS").

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=41

Multiple 'remove' links when 'extra' used as formTemplate

From [email protected] on September 26, 2011 17:42:41

What steps will reproduce the problem? 1. Create an inline formset with 'extra' and hide the extra with jQuery
2. Choose a row of extra as formTemplate
3. Click 'add' in browser What is the expected output? What do you see instead? Instead of one, there are several delete links per new row What version of the product are you using? On what operating system? Trunk. Debian Squeeze Please provide any additional information below. Commenting out line 135:
insertDeleteLink(template);
fixed it for me, but you'd probably like to put it in a conditional clause

Advantages of choosing (and hiding) 'extra' as formTemplate:

  • fallback for noscript
  • new rows autofilled from models.py

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=35

problematic situation with 2 formsets

From [email protected] on June 05, 2011 14:50:24

What steps will reproduce the problem? example:

  1. suppose an edit view with 2 formsets(formsetA and formsetB) and extra=1
  2. without using 'formTemplate': delete all (empty) field in formsetA, fill something wrong a form in formsetA. Submit. "Add button" is missing in formset B, because "anchor point" is missing.
  3. using 'formTemplate', if one formset has data (because it's an edit page) and 'extra=1'how can I render it properly? What version of the product are you using? On what operating system? Revision 17 : /trunk
    Django 1.3

Tricky solution (but i don't like it) with use of "for"(and empty):

[...]

<script> $(function() { $('#formsetB .formB').formset({ prefix: '{{ formsetB.prefix }}', formTemplate: '#empty-formB', }); }) </script>

[...]

{% with formsetB.empty_form as form %}

{{ form.type.label_tag }}:{{ form.type }} {{ form.value.label_tag }}:{{ form.value }}

{% endwith %}

{% for form in formsetB.forms %}
{{ form.id }} {% if form.type.errors %}{{ form.type.errors }}{% endif %} {{ form.type.label_tag }}:{{ form.type }} {% if form.value.errors %}{{ form.value.errors }}{% endif %} {{ form.value.label_tag }}:{{ form.value }} {% if form.instance.pk %}{{ form.DELETE }}{% endif %}
{% empty %}
{% endfor %} {{ formsetB.management_form }}

[...]

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=29

Lock AddItem button if some field is empty

From [email protected] on September 27, 2012 22:40:11

Hi, sorry my english. I need lock the crations of new rows if a field value is ''. For use it:

$('#form').formset({
...
lockEmptyPattern: 'input[type="text"]'
});

This, check if the inputs fields have content, if don't have nothing, you can't create a new row, and the empty field is focused.

Other example, with customize action:

$('#form').formset({
...
lockEmptyPattern: '*[required]',
lockEmptyCallback: function (element) {
alert("Field " + element.get(0).tagName + " is required");
}
});

I attach a patch file.

Attachment: jquery.formset.js-lockEmptyPattern.patch

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=49

updated ids are incorrect

From [email protected] on June 18, 2010 00:37:53

What steps will reproduce the problem? 1. Use any of the demo applications.
2. View the input element ids using Firebug or equivalent. What is the expected output? What do you see instead? I would expect ids that look like "id_form-0-value", but instead I see "form-1-id_form-0-value". What version of the product are you using? On what operating system? Latest SVN, Firefox on Ubuntu. Please provide any additional information below. The problem is this regex:

var idRegex = new RegExp('(' + prefix + '-\d+-)|(^)')

This always matches the start of the string unless the prefix happens to be right at the start (like it is with the name attribute). I'm not sure what the purpose of the second group in the regex is. If it is to deal with empty attributes, this will work better:

var idRegex = new RegExp('(' + prefix + '-\d+-)|(^$)')

Thanks,
Forest

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=9

Multiple deleteCssClass values causes jQuery to not match query

From [email protected] on May 14, 2012 13:22:56

What steps will reproduce the problem? 1. Set deleteCssClass to have multiple values (e.g. "btn btn-danger") What is the expected output? What do you see instead? Remove link should have click handler event bound properly. Instead, no matches are found and nothing happens when the delete link is clicked. What version of the product are you using? On what operating system? 1.2 - Mac OS X 10.7.3 Please provide any additional information below.

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=44

Adding a row, and removing the first row causes ValueError exception

From nick.bolton.uk on November 22, 2009 18:30:01

What steps will reproduce the problem? 1. Create an instance of a formset with an instance.
2. Remove the first row.
3. Add a row to the end. What is the expected output? What do you see instead? I expect this to behave just as it would when the first row is not removed. What version of the product are you using? On what operating system? # Django
VERSION = (1, 1, 0, 'final', 0) Please provide any additional information below. Exception Type: ValueError
Exception Value: invalid literal for int() with base 10: ''
Exception Location: C:\Python25\lib\site-
packages\django\db\models\fields__init__.py in get_db_prep_value, line 361

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=3

The "add another" link doesn't respect MAX_NUM_FORMS.

From [email protected] on June 29, 2010 20:59:44

The "add another" link doesn't respect MAX_NUM_FORMS.

I might have over looked something but the dynamic adding doesn't seem to support the max_num property of the formset as represented by MAX_NUM_FORMS. I didn't find a setting to make this work. I might be able hack enough with the add and remove hooks to make this work but an internal solution seems more natural.

If this should be dealt with inside the main code base I should be able to provide a patch tomorrow. If I have just missed something please let me know.

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=10

Suggest fix for resetting dropdown values

From [email protected] on August 24, 2012 10:26:53

I'm using version 1.2 of django-dynamic-formset. I really like it but I would like to suggest a change.

I've noticed when you add a new form it keeps the old dropdown values.

So I've changed my local copy to allow for this and I'm just sharing the changes I've made (see attached diff) incase you would like to add this patch.

Attachment: select_reset.diff

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=47

Patch for /trunk/src/jquery.formset.js

From [email protected] on June 04, 2012 22:35:18

Currently, the formset module removes rows before calling the row.removed function. The problem with this behavior is that when a developer is working with multiple formsets on a single page, they cannot select the proper one based on the parent of the removed row. This patch will simply pass through the immediate parent of the removed row to the removed function, so that selecting based off the parent is possible. If there is some way that I am not aware of to do this without passing through the parent, please let me know, I am curious. Thanks.

Attachment: jquery.formset.js.patch

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=46

Add option to not automatically add Add/Delete links to formsets

From [email protected] on February 20, 2010 19:55:37

My template include some more complex add/delete formset links already
inside formset so there is no need to add them to the end. A simple CSS
class added to the anchor tag is not enough for my use.

The attached patch adds an option called autoAddLinks that you can set to
false to prevent any links being added.

Attachment: jquery.formset-add_option_to_not_auto_add_adddel_links.patch

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=6

Inline Formset Doesn't Work in Chrome

From [email protected] on December 27, 2010 08:15:02

What steps will reproduce the problem? 1. Installed current trunk of django-dynamic-formset jQuery plugin
2. Leverage inline formset demo to get working form - add/remove/etc within Internet Explorer

  1. Test jQuery plugin within the Google Chrome Browser v8. What is the expected output? What do you see instead? Still works in Internet Explorer as expected.
    Form renders fine in Chrome, but both remove and add functionality doesn't change data when POSTing. What version of the product are you using? On what operating system? Current trunk as of December 27, 2010, Windows 7, Google Chrome v8, jquery-1.3.2

I would be happy to supply additional information.

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=20

the regex used to replace the id, label for and name doesnt work for id and labels

From [email protected] on September 03, 2010 21:41:42

it seems to me that the regex (new RegExp('(' + prefix + '-\d+-)|(^)')) doesn't work because the OR part (|(^)) always match, so where you do something as

"id_form-2-name".replace(regex, "form-3-name"), the regex will match (^) and the result will be "form-3-nameid_form2-name".

changing the regex to RegExp('(' + prefix + '-\d+-)|(^ *$)') solves the problem. I don't know if this is the desired behavior, but it works for me like this.

thanks
bruno

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=16

"Add another" link rendered overlapped in IE 8 (jQuery 1.6.x incompatibility)

From [email protected] on October 14, 2011 23:54:53

What steps will reproduce the problem? 1. Create formset using table. Use jQuery 1.6.x
2. IE 8 will render overlapped "Add another" link. This is because there is no TR>TD container provided for a link. What is the expected output? What do you see instead? "Add another" link should be placed inside TR>TD. What version of the product are you using? On what operating system? jQuery 1.6.4 Please provide any additional information below. This issue caused by change in jQuery 1.6 http://bugs.jquery.com/ticket/9228 Fix is pretty easy, use:
if ($$.attr('tagName') || $$.prop('tagName') == 'TR')
istead
if ($$.attr('tagName') == 'TR')

attr('tagName') is left for compatibility with older jQuery, where no prop method ( http://api.jquery.com/prop ) available.

Attachment: jquery.formset.js

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=38

Few formsets on one page

From [email protected] on February 02, 2011 14:14:18

What steps will reproduce the problem? 1. Add few formsets in a page, for instance

{{ formset1.management_form }}
{% for form in formset1.forms %}


{{ form }}

{% endfor %}

<script type="text/javascript"> $('.form1').formset({ prefix: '{{ formset1.prefix }}', addText: '+', deleteText: '-', }) </script>

{{ formset2.management_form }}
{% for form in formset2.forms %}


{{ form }}

{% endfor %}

<script type="text/javascript"> $('.form2').formset({ prefix: '{{ formset2.prefix }}', addText: '+', deleteText: '-', }) </script>
  1. Press delete button for one form
  2. Attribute 'name' will be changed in elements of another form

Little patch for fix this bug.

Attachment: delete.patch

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=23

Multikey value error if script is used for multiple objects

From [email protected] on January 18, 2012 17:39:20

Immagine a nested model:

grandparent > parent > son

If you have a page with 1 "parent" and the "son" formset relative to that "parent" everything is fine.

I wanted to have a page with all the "parents" related to a specific "grandparent" divided by tabs and for each of that "parent" (in each tab) I wanted to have the "son" formset.
In this case if I add a new son with the add button and then I remove it and save I get a "MultiValueDictKeyError" from django. This happens because some input names attributes are not renamed correctly.
I couldn't fix the regular expression (and I don't know if it behaves strangely because something I did wrong) so I found a workaround.
Because each parent is contained in a tab which has a specific class I tweaked the code so that in these cases you can specify the class of the container of each "parent" so that when input names are renamed the script renames only the inputs of the "parent" actually editing and not all the other ones.

It's quite difficult to explain.. I attach the patch, the changes are anticipated by comments containing "EDIT BY NEMESIS"
If you want to see how I'm using it contact me privately (i leave my email in the first 2 lines of the script) and I'll give you access to the application in which i'm using the patched script. What is the expected output? What do you see instead? What version of the product are you using? On what operating system? Please provide any additional information below.

Attachment: jquery.formset.js

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=42

Adding new form rows fails with multiple formsets

From [email protected] on July 06, 2011 19:53:10

What steps will reproduce the problem? 1. Create a form which contains two different formsets
2. Click the add button of the first formset
3. The new form row is added to the second formset
4. Click the add button from the second formset and it will add a new row .. but using the first formset as template

I've provided a patch for this, however it changes slightly the usage because it requires the formsets to be wrapped into a block element that has a formset class (the element type doesn't matter).

Ex:

{# formset 1 goes here #}
{# formset 2 goes here #}

Attachment: formset.patch

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=32

jquery.formset.js-generated checkbox elements always return False in Django

From [email protected] on October 21, 2009 19:31:51

What steps will reproduce the problem? 1. In Django, create a form with a field:
mycheckbox = forms.booleanField(required=False)
2. Set jquery.formset.js to do it's thing on said form
3. Render the page in a browser, click 'add' to generate another form on
the page
4. Check the checkbox element on the newly added form
5. Submit the form, validate it through Django
6. Look at form.cleaned_data['mycheckbox'] - it is False, despite the
checkbox being checked What is the expected output? What do you see instead? On a POST or GET submission of a form, input elements of type="checkbox"
will either not get sent in headers/params or will get sent containing
their value attribute (default value is 'on' if it is not set).

Currently, when a new form is generated, $(this).val('') gets called on all
copied elements, which sets their value attributes to ''. When this happens
in a checkbox input element, it alters the behavior of the checkbox
element, making an empty string get sent as the value if it is checked.
When Django processes the checkbox field, the
form.cleaned_data['mycheckbox'] will always return False on the checked
input element of a generated/added form. What version of the product are you using? On what operating system? v1.0 Please provide any additional information below. I've attached a patch. I'm very new to jQuery so this is probably not the
most elegant fix but the intent should be clear.

Thanks for the awesome plugin!

Attachment: dynamic-forms-checkbox-fix.patch

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=1

Radio select in initial form is wiped when a new form is added

From brianna.laugher on August 17, 2010 06:34:13

I have a form that has input type=text, input type=radio and select elements. The input type=text and the input type=radio have default text/selections.

When I add a new form, the new form has no text or selections (as expected), but it also removes the radio selection in the initial form.
It doesn't alter the select or the input type=text fields.

I am using a prefix. I'm also using Jquery v1.4.2. I will attach a file that demonstrates the problem.

Attachment: test.html

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=14

Demo application refers to jquery.formset.js that does not exist

From [email protected] on March 30, 2010 14:58:24

What steps will reproduce the problem? 1. Start demo
2. Go to http://localhost:8000/
3. Check source: refers to /static/js/jquery.formset.js What is the expected output? What do you see instead? - expected: script file is found

  • now: 404 error, directory contains only jquery.formset.min.js What version of the product are you using? On what operating system? SVN revision 10 (head), Windows XP, Django 1.1 Please provide any additional information below. Solved by copying missing file from /src directory.

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=7

inline-formset-autocomplete.html crashes upon submission

From [email protected] on January 13, 2011 12:06:33

What steps will reproduce the problem? 1. Go to the inline-formset-autocomplete example and hit "submit". it crashes.

What do you see instead?
Environment:

Request Method: POST
Request URL: http://localhost:8000/examples/inline-formset-autocomplete/
Django Version: 1.2.3
Python Version: 2.6.6
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'example']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware')

Traceback:
File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in get_response

  1.                 response = callback(request, _callback_args, *_callback_kwargs)
    
    File "/home/bshanks/prog/pietrust/pie-share/j/demo/example/views.py" in inline_formset
  2.     formset = OrderedItemFormset(request.POST, instance=order)
    
    File "/usr/lib/pymodules/python2.6/django/forms/models.py" in init
  3.                                             queryset=qs)
    
    File "/usr/lib/pymodules/python2.6/django/forms/models.py" in init
  4.     super(BaseModelFormSet, self).**init**(**defaults)
    
    File "/usr/lib/pymodules/python2.6/django/forms/formsets.py" in init
  5.     self._construct_forms()
    
    File "/usr/lib/pymodules/python2.6/django/forms/formsets.py" in _construct_forms
  6.         self.forms.append(self._construct_form(i))
    
    File "/usr/lib/pymodules/python2.6/django/forms/models.py" in _construct_form
  7.     form = super(BaseInlineFormSet, self)._construct_form(i, **kwargs)
    
    File "/usr/lib/pymodules/python2.6/django/forms/models.py" in _construct_form
  8.         pk = self.data[pk_key]
    
    File "/usr/lib/pymodules/python2.6/django/utils/datastructures.py" in getitem
  9.         raise MultiValueDictKeyError("Key &#37;r not found in &#37;r" &#37; (key, self))
    

Exception Type: MultiValueDictKeyError at /examples/inline-formset-autocomplete/
Exception Value: "Key 'ordered_items-0-id' not found in <QueryDict: {u'ordered_items-0-quantity': [u'5'], u'ordered_items-2-quantity': [u'1'], u'ordered_items-3-product': [u'3'], u'ordered_items-5-quantity': [u''], u'ordered_items-3-quantity': [u'3'], u'ordered_items-1-order': [u'1'], u'ordered_items-4-product': [u'3'], u'ordered_items-0-product': [u'1'], u'ordered_items-2-product': [u'7'], u'ordered_items-5-product': [u''], u'ordered_items-1-quantity': [u'1'], u'ordered_items-INITIAL_FORMS': [u'5'], u'ordered_items-2-order': [u'1'], u'ordered_items-0-order': [u'1'], u'ordered_items-4-order': [u'1'], u'ordered_items-TOTAL_FORMS': [u'6'], u'ordered_items-4-quantity': [u'5'], u'customer': [u'Kermit the frog'], u'ordered_items-1-product': [u'3'], u'ordered_items-MAX_NUM_FORMS': [u''], u'ordered_items-5-order': [u'1'], u'ordered_items-3-order': [u'1']}>" What version of the product are you using? On what operating system? 1.2 Firefox GNU/Linux Please provide any additional information below. the template "inline-formset-autocomplete.html" is missing the following two lines which are in inline-formset.html. If you add them it doesn't crash:

                        {&#37; for fld in form.hidden_fields &#37;}{{ fld }}{&#37; endfor &#37;}
                        {&#37; if form.instance.pk &#37;}{{ form.DELETE }}{&#37; endif &#37;}

thanks for all your work on django-dynamic-formset, it's really neat!

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=21

Is there a way of deleting data in the db without using Delete checkbox?

From nick.bolton.uk on November 22, 2009 18:32:27

There doesn't seem to be a mailing list, so I figured this is the best place
to post my issue.

I noticed that removing a dynamic row will not remove the row in the db, and
the only way to do this is to check the Delete checkbox and save.

Is there a way of setting a row's delete value to "true" and then hiding the
row, instead of removing it?

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=4

syncdb with demo fails if ajax_select not installed

From [email protected] on September 29, 2011 22:32:24

What steps will reproduce the problem? 1. Ensure ajax_select module is not installed
2. cd demo/
3. python manage.py syncdb What is the expected output? What do you see instead? I get "ImportError: No module named ajax_select" What version of the product are you using? On what operating system? SVN r17 of django-dynamic-formset

$ python manage.py --version
1.2.5

Running on Ubuntu 11.04. Please provide any additional information below. I did not see this dependency mentioned in any of the django-dynamic-formset files or on the project website, so it should be added somewhere. I fixed the issue on Ubuntu with the following:

$ apt-get install django-ajax-selects

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=36

django-dynamic-formset is not an installable python package

From [email protected] on August 23, 2011 21:32:45

What steps will reproduce the problem? 1. Run 'pip install -E svn+ http://django-dynamic-formset.googlecode.com/svn/trunk' What is the expected output? What do you see instead? Expected: Package is installed.
Actual: Error because setup.py does not exist. What version of the product are you using? On what operating system? r17 , mac os x Please provide any additional information below. We should add a setup.py file so that django-dynamic-formset can be installed automatically using a pip/virtualenv solution.

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=34

Replacement Regular expression

From [email protected] on May 11, 2011 08:05:14

What steps will reproduce the problem? add a row to a formset. "id" and "for" Elements attributes are not generated correctly. "Id" and "For" contains "id_" prefix thats mismatch the replacement regular expression.

I use this one : var idRegex = new RegExp('(.)' + prefix + '-\d+-(.)'),
replacement = '$1' + prefix + '-' + ndx + '-$2'; What is the expected output? What do you see instead? What version of the product are you using? On what operating system? jQuery Formset 1.2
Django 1.3

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=28

Empty rows being saved or validation error on formset for existing instance data

From [email protected] on February 08, 2011 18:17:32

What steps will reproduce the problem? 1.Create a new instance using a form with an inline formset and this jquery plugin
2.Save the form after adding several items to the formset. Have the extra flag set to at least one
3.Edit the form and click the remove link next to a formset item that was already created in the previous step
4. Save the form

What is the expected output?
The form should save and the item that you removed should be removed

What do you see instead?

If the model class field is set to required for the formset, the formset will fail validation. If the field is set to null=True and blank=True the save will insert an empty record What version of the product are you using? On what operating system? 1.2 of the plugin and 1.2.3 of DJango Please provide any additional information below. If you create a new form and have extra set to 1 or any other number, the formset is not creating a blank item or failing validation for all of the empty rows. It seems to only happen when you edit an existing form. The only way to pass validation is to remove all the empty rows.

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=24

Cannot update options formset has been called.

From [email protected] on September 19, 2012 05:01:02

I am doing nested formsets, which makes everything quite subtle and complicated (at least it seems that way to me). I'll try to make sense, apologies if I don't :-)

The explicit problem that I have is around deletion of rows from the outermost formset leaving .prefix wrong on subsequent instances of the inner formset.

Assume the following initial structure:

outer-formset-0
inner-formset-0-empty-form
outer-formset-1
inner-formset-1-empty-form
outer-formset-empty-form

I have only slightly hair raising code to call formset on the outer formset (with prefix=="outer-formset") and inner formsets (with prefix "inner-formset-0" and then "inner-formset-1").

Then: delete outer-formset-0, add a formset to the remaining outer-formset and submit the form. The data from the added formset will not end up in the right place.

What's happened? Well, when outer-formset-0 got deleted, the 'id's and 'name's of the input elements of inner-formset-1-empty-form got munged (s/inner-formset-1/inner-formset-0) -- but the .prefix in the options object of the formset is still "inner-formset-1"! So when you clone the empty form adding a new row, the input elements do not have the 'id' and 'name' munged. Hence the problem.

Now, if there was some magical way of making this work that would be create. But I can't see it, so I've worked around it by hacking my copy of jquery.formset.js to do this:

        $$.data('options', options);

And then in the 'removed' callback, I iterate through all the inner formsets and make sure prefix is set correctly. What version of the product are you using? On what operating system? r20 from svn. Please provide any additional information below. Thanks for reading this far!

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=48

Not compatable with django-ajax-select

From [email protected] on September 14, 2010 15:20:52

http://code.google.com/p/django-ajax-selects Using both together would be great. Sadly they do no seem to work together. I see two problems when using both

  • ajax select does not work with added fields, the required javascript I assume is not copied to new fields.
  • ajax multiple select stops working altogether. Instead of adding the selected object under the textfield, it appears in the textfield itself which is not usable.

If I can come up with a fix I'll post it. Using both would make for some really nice formsets!

Original issue: http://code.google.com/p/django-dynamic-formset/issues/detail?id=17

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.