Commits

Dmitri Lebedev committed 3225200

fixes

  • Participants
  • Parent commits a83291f

Comments (0)

Files changed (2)

example/django_inline/__init__.py

 				row_ender = '</span>',
 				help_text_html = u' %s',
 				errors_on_separate_row = False)
+
+	return FormClass

example/django_inline/views.py

 from django.shortcuts import render_to_response, get_object_or_404
 from django.template import RequestContext
 
-from django_inline import templates_list
+from django_inline import templates_list, form_class
 
 
 def _raise_error(label):
         model = get_model(app_label, class_name)
         obj = get_object_or_404(model, pk=int(pk))
         
-        class FormClass(forms.ModelForm):
-            class Meta:
-                model = obj.__class__
-                fields = (field_name,)
-            
-            def as_inline(self):
-                "Returns this form rendered as HTML <li>s -- excluding the <ul></ul>."
-                return self._html_output(
-                    normal_row = u'<span%(html_class_attr)s>%(errors)s %(field)s</span>',
-                    error_row = u'<span>%s</span>',
-                    row_ender = '</span>',
-                    help_text_html = u' %s',
-                    errors_on_separate_row = False)
-
-        
-        return func(request, app_label, obj, field_name, id, FormClass)
+        return func(request, app_label, obj, field_name, id)
 
     return decorated
 
 
 @get_params
-def widget(request, app_label, obj, field_name, id, FormClass):
+def widget(request, app_label, obj, field_name, id):
     """
     Creates a form on the fly and renders it in a template.
 
 
     You can override the template with your own. It has to be named 'inline-form.html', and can be put in templates/%app_name%/%model_name%, templates/%app_name% or templates folder (folders are searched in the given order).
     """
-    class NewFormClass(FormClass):
+    class NewFormClass(form_class(obj, field_name)):
         id = forms.CharField(widget=forms.HiddenInput())
     
     form = NewFormClass(initial={'id': id, field_name: getattr(obj, field_name)})
 
 
 @get_params
-def update(request, app_label, obj, field_name, id, FormClass):
+def update(request, app_label, obj, field_name, id):
     """
     Checks user permissions and saves the data in the model.
     """
     if request.user.has_perm('%s.can_edit' % obj.__class__.__name__, obj):
-        form = FormClass(data=request.POST, files=request.FILES, instance=obj)
+        form = form_class(obj, field_name)(data=request.POST, files=request.FILES, instance=obj)
         form.save()
 
     return render_to_response(