-
Notifications
You must be signed in to change notification settings - Fork 290
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
Feature Request: better support for inline formsets #78
Comments
I have added ng-model to the management form by modifying it in the
|
Pushing an unknown number of forms into the array is going to be problematic. Clearly we will need to initialize the array in the controller, but it can't be empty. When we put an ng-model property like this:
For my application I am going to set the max number of forms at 20, and initialize the array like so:
This is going to work just fine for my use case, but doesn't seem robust enough to put into django-angular. Edit: I think I'll put something in the controller to remove the empty objects after the page loads. Obviously far from ideal. |
The Zen of this project is to do stuff such as form rendering the “Djagno”-way. First, when I started, I was proud to not have any Javascript code at all. Well, these times are gone, but JS still takes a small footprint of the project. I therefore prefer to use Django templates for rendering, etc. Since I'am short of time, I'll come back to this in a month or so. |
I think that Zen is one of the things I like about this project, myself having been acquainted with Django much longer than Angular. I'll keep that in mind as I am working on my implementation. One of my requirements is to be able to add/remove inline forms on the client, so some javascript is going to be needed. |
I have a InlineFormset that I want to validate . Can this plugin do that.??? |
AngularJS doesn't know about the concept of formsets. In AngularJS the form validation is done using the |
Thanks I will try. Right now I am trying to integrate bootstrap formvalidation plugin. But due to different names it is now working. |
I solved the Management Form issue in what I believe is a more elegant way, using a template tag to render it.
|
There's one final issue that I haven't seen solved in any of these tickets regarding formsets. add_prefix in NgFormBaseMixin changes dots to dashes, which works fine for regular forms because that same add_prefix is called during validation. This is not true during formset validation, however. _construct_form in django.forms.models.BaseModelFormSet has the dash hard-coded. Is this a bug in django? I'm going to work around it for now, but this would have to be addressed if this will someday be supported in django-angular. |
@Ivan0xFF Would you like to contribute and add your work to django-angular? Better support and documentation is one of the last thing lacking for this module. (Beside Angular2 which is another subject) |
I am currently working on implementing inline formsets locally. Has anyone else used django-angular with inline formsets.
What I have in mind is putting the inline forms into an array, so I can use ng-repeat as I add or remove forms.
so the scope_prefix object would look something like this:
The other issue to address is putting ng-model on the django management forms, so those can be manipulated as forms are added/removed.
I am opening this issue as a place to keep track of how to implement this, if my workload permits I will update the demo and docs when I get it working. Any feedback or ideas are greatly appreciated.
The text was updated successfully, but these errors were encountered: