zopefoundation / z3c.form

An advanced form and widget framework for Zope 3
Other
8 stars 39 forks source link

Adding json method for zope forms #22

Closed mmilkin closed 8 years ago

mmilkin commented 9 years ago

JSON Forms

What: This pull request will allow users to render zope forms to a json format.

Added two top level methods IForms.json() this will return the form in a json format IWIdget.json_data() this will return a dictionary representation of the widget.

Examples

Form:

{'errors': [<Form Level Errors> ...],  
  'fields': [<Widgets.json_data()> ...],
 'mode': '<Form Mode>',
 'prefix': '<Form Prefix>',
 'status': '<Form Status>'}

Widgets:

{'error': 'Widget Error Message',
  'id': '<Widget Id if it has one>',
  'mode': '<Widget input>',
  'name': '<Widget Name>',
  'required': <Widget Required>,
  'type': 'text',
  'value': '<Widget Value>'},
mauritsvanrees commented 8 years ago

Looks good, thanks. I have merged it. Sorry for the long wait (almost a year)!