Allow overriding form class/factory for CRUD views.
This commit is contained in:
parent
9f8a3d3a5c
commit
a11b8d9ff2
|
@ -26,7 +26,7 @@
|
|||
FormAlchemy Forms
|
||||
"""
|
||||
|
||||
from edbob import Object
|
||||
from rattail.core import Object
|
||||
from pyramid.renderers import render
|
||||
from ..db import Session
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ class CrudView(View):
|
|||
def fieldset(self, model):
|
||||
return self.make_fieldset(model)
|
||||
|
||||
def make_form(self, model, **kwargs):
|
||||
def make_form(self, model, form_factory=AlchemyForm, **kwargs):
|
||||
if self.readonly:
|
||||
self.creating = False
|
||||
self.updating = False
|
||||
|
@ -99,7 +99,7 @@ class CrudView(View):
|
|||
kwargs.setdefault('cancel_url', self.cancel_url)
|
||||
kwargs.setdefault('creating', self.creating)
|
||||
kwargs.setdefault('updating', self.updating)
|
||||
form = AlchemyForm(self.request, fieldset, **kwargs)
|
||||
form = form_factory(self.request, fieldset, **kwargs)
|
||||
|
||||
if form.creating:
|
||||
if hasattr(self, 'create_label'):
|
||||
|
|
Loading…
Reference in a new issue