Skip to main content

z3c.form widget to manage a json field.

Features

  • Customizable schema

Usage

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',
        required=True,
    )
    second = schema.List(
        title="second field",
        required=False,
        value_type=schema.TextLine(),
    )

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"]
    },
]

Translations

This product has been translated into

  • Italian

Installation

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

[buildout]

...

eggs =
    collective.z3cform.jsonwidget

and then running bin/buildout

Contribute

Credits

Developed with the support of Regione Emilia Romagna;

Regione Emilia Romagna supports the PloneGov initiative.

Authors

This product was developed by RedTurtle Technology team.

RedTurtle Technology Site

Contributors

Changelog

2.0.1 (2026-07-07)

  • Fixed wrong logger import in upgrade. [daniele]

2.0.0 (2026-03-26)

  • Plone 6 compatibility. Use 1.x tags for Plone < 6. [cekk] [cekk]

1.1.2 (2023-04-26)

  • Fix release. [cekk]

1.1.1 (2023-04-21)

  • Handle integer fields. [cekk]

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]

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-2.0.1.tar.gz (758.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

collective_z3cform_jsonwidget-2.0.1-py3-none-any.whl (705.7 kB view details)

Uploaded Python 3

File details

Details for the file collective_z3cform_jsonwidget-2.0.1.tar.gz.

File metadata

File hashes

Hashes for collective_z3cform_jsonwidget-2.0.1.tar.gz
Algorithm Hash digest
SHA256 8dbc3dcd1d544820af5cd56f007f5e8be71a75d573a87ec19bc714933ab4684e
MD5 91504d43050a6c414435191c486fa653
BLAKE2b-256 02fa5b621791b1ce55af27273e8462bf60d7639372e4bc7884aaac20ad0f7e79

See more details on using hashes here.

File details

Details for the file collective_z3cform_jsonwidget-2.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for collective_z3cform_jsonwidget-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2a08e95d69782af285ed1d41fd179cc31b30e697a1b2f56e14f2df675471552a
MD5 909447cf51a2e15118b1b7aa60368e59
BLAKE2b-256 55258413cbb1ccb4f8f528a9a3772fba7449ca970f3264f56100e37cb36d3483

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page