Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
elo80ka opened this issue Feb 27, 2014 · 5 comments

Comments

@elo80ka
Copy link
Owner

elo80ka commented Feb 27, 2014

From qgriff...@gmail.com 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

@elo80ka elo80ka self-assigned this Feb 27, 2014
@elo80ka
Copy link
Owner Author

elo80ka commented Feb 27, 2014

From stan.madueke on February 08, 2011 21:07:12

Status: Accepted
Owner: stan.madueke

@elo80ka
Copy link
Owner Author

elo80ka commented Feb 27, 2014

From qgriff...@gmail.com on February 13, 2011 11:12:03

I think I may of fixed this issue. I grab the latest copy of your java script. I also re-wrote my form template and removed a call back function I was doing when a new row was added. Since then I have not been able to re-produce the issue.

@elo80ka
Copy link
Owner Author

elo80ka commented Feb 27, 2014

From stan.madueke on February 14, 2011 05:52:02

Yay! That's good news. D'you mind posting the details of your callback method? It'd be nice to know for sure, before I close this.

@elo80ka
Copy link
Owner Author

elo80ka commented Feb 27, 2014

From qgriff...@gmail.com on February 14, 2011 06:17:40

This is what I was using

 <script type="text/javascript">
     $(function() {
         $('tbody tr').formset({
             prefix: '{{ formset.prefix }}',
             added: function(row){
                 var aisle = row.find('td.aisle input');
                 aisle.val('other');

             },
             extraClasses: ['row1', 'row2']
         });
     })


 </script>

I am not 100% sure I was using version 1.2 of your library. Both version 1.1 and 1.2 have this in the source code at the top

  • jQuery Formset 1.1
  • @author Stanislaus Madueke (stan DOT madueke AT gmail DOT com)
  • @requires jQuery 1.2.6 or later

So I updated the library to be on the safe side.

@elo80ka
Copy link
Owner Author

elo80ka commented Feb 27, 2014

From stan.madueke on February 14, 2011 06:41:52

That seems benign...don't see how that'd cause anything to stop working. I guess the wrong version number in the code is the real bug here :) I'll go ahead and close this then. Thanks!

Status: Fixed

@elo80ka elo80ka closed this as completed Feb 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant