Download the PHP package fiedsch/contao-jsonwidget without Composer
On this page you can find all versions of the php package fiedsch/contao-jsonwidget. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package contao-jsonwidget
JSON and YAML Widgets for Contao
The jsonWidget
can be used in DCA files to create a text field that contains a JSON string.
While saving it will be checked if that the string is valid JSON.
The widget displays the JSON string with JSON_PRETTY_PRINT
so that checking/finding errors
is easier for the user.
The yamlWidget
is mostly the same, except that it uses the YAML format.
Example: extending Members
DCA
Other valid options in eval
are the same as for textarea
s (as WidgetJSON
extends TextArea
),
except that setting rte
will be ignored because the editors provided do not make sense here.
How to use the JSON data?
Extend tl_member
as in the above example. Then create an ExtendedMemberModel
that
extends Contao's MemberModel
. In the magic methodd __set()
and _get
you can intercept
the "fields" stored in json_data
. The Fiedsch\JsonWidgetBundle\JsonGetterSetterTrait
takes
care of that:
Using the Model
YAML-Syntax Highlighting with ACE
Set
in your field's DCA definitions.
Quick and dirty way: add desired CSS-Rules like e.g.
to your be_ace.html5
(which you create it if you do not yet have a custom version).
OR: use a custom backend style and add the CSS rules there.
Set JSON (or JAML) Data
If you want to set all the JSON (or YAML) data at once you cannot use
To do this you have to use
Note that this way previously set JSON (or YAML) data is overwritten.
Also note that the behaviour of setJsonColumnData([])
(when setting an empty data array) changed in version 0.5.0
. Previously it created []
where it
now creates {}
in the respective database column.
In version 0.7.0
we slightly changed this again to achieve the original goal: The storage of empty arrays as object ({}
) is only enforced on the top level
of the data. In lower levels, empty arrays will be stored as arrays ([]
) not as "empty" objects ({}
): compare
{ "foo": [] }
(versions >= 0.7.0) to { "foo": {} }
(versions >=0.5.0 and <0.7.0).
All versions of contao-jsonwidget with dependencies
ext-json Version *
contao/core-bundle Version ^4.9 || ^5.1
symfony/yaml Version ^4.2 || ^5.0 || ^6.0