Implement tri.form rendering ?
Currently, chp renders Django forms just fine.
However, a quick study of tri.form made it look like a vastly superior alternative.
Their only trick that would break compatibility is
form.save(), that will become
form.apply(instance); instance.save(). This is a change that we can definitely afford in projects, and we'd get a lot better form library for free, potentially, if this can work.
See for yourself how it allows to define nested field/widget attributes:
form = Form.from_model( request.POST, User, # the field 'name' is generated automatically and we are fine with the defaults username__is_valid=lambda form, field, parsed_data: parsed_data.startswith('demo_'), is_admin__label_template='tweak_label_tag.html', is_admin__show=lambda form, field: form.request.user.is_staff) # show only for staff
As for rendering:
class UserForm(Form): name = Field.text() username = Field.text(is_valid=lambda form, field, parsed_data: parsed_data.startswith('demo_')) is_admin = Field.boolean( show=lambda form, field: form.request.user.is_staff, # show only for staff label_template='tweak_label_tag.html')
As you can see, it uses the template backend using a template name for rendering. Do you think we can hook components with
label_template='your.TweakTag' using a django template backend ? I was pretty happy with the simple one I wrote.
I have not found formset support. Formsets are a nice thing from Django that would be great to enhance... the management form part, could be revisited a bit.
Request for comments ;)