Skip to main content

Custom widget to manage complex json data stored into a text field

Project description

z3c.form widget to manage a json field.


  • Customizable schema


You need to set the widget to needed fields into your form instance:

from collective.z3cform.jsonwidget.browser.widget import JSONFieldWidget
from zope.interface import Interface
from zope import schema

class IMyJsonSchema(Interface):
    first = schema.TextLine(
        title='first field',
    second = schema.List(
        title="second field",

class IFormSchema(Interface):
    my_json_field = schema.SourceText(
        title="The field with some stored json values"

class MyForm(Form):

    schema = IFormSchema
    fields = field.Fields(IFormSchema)
    fields["my_json_field"].widgetFactory = JSONFieldWidget

    def updateWidgets(self):
        super(MyForm, self).updateWidgets()
        self.widgets["my_json_field"].schema = IMyJsonSchema

With this configuration, we are setting JSONFieldWidget widget to my_json_field field and setting the fields schema defined in IMyJsonSchema interface.

In the field are stored a list of json objects where each object has a set of fields defined in the schema.

For example for the given configuration, we are going to store into the field something like:

        "first": "a string",
        "second": [1,2,3,4]
        "first": "another string",
        "second": ["a", "b", "c"]


This product has been translated into

  • Italian


Install collective.z3cform.jsonwidget by adding it to your buildout:



eggs =

and then running bin/buildout



Developed with the support of Regione Emilia Romagna;

Regione Emilia Romagna supports the PloneGov initiative.


This product was developed by RedTurtle Technology team.

RedTurtle Technology Site



1.1.0 (2022-07-18)

  • Force vocabularies batch size to 1000 to get all of possible values. [cekk]

1.0.0 (2021-12-20)

  • Improve widget usability. [cekk]

0.2.4 (2021-12-13)

  • Fix defaulValue in select fields. Now we can also reset the values. [cekk]

0.2.3 (2021-08-18)

  • Fix homepage breadcrumb. [cekk]

0.2.2 (2021-08-17)

  • Fix breadcrumbs and pagination in ReferenceField. [cekk]

0.2.1 (2021-05-18)

  • Add alt text on buttons

  • Add locales for a11y hints [nzambello]

0.2.0 (2021-05-17)

  • Add link and path to referenced items [nzambello]

  • Fix TextLine field. [cekk]

0.1.0 (2021-02-09)

  • Initial release. [cekk]

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

collective.z3cform.jsonwidget-1.1.0.tar.gz (310.1 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page