tonisormisson/yii2-json-form

There is no license information available for the latest version (1.4.2) of this package.

The JSON form view widget for yii2

Installs: 148

Dependents: 0

Suggesters: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

1.4.2 2018-12-04 11:21 UTC

README

Example usage

<?php 
use tonisormisson\jsonform\JsonForm;

$jsonData = '{"username":"admin","password":"password"}';
$variables = [
    'username'=>[
        'label' => Yii::t('app','Username'),
    ],
    'password'=>[
        'label' => Yii::t('app','Password'),
        'type' => JsonForm::TYPE_PASSWORD,
    ],
];

echo JsonForm::widget([
    'id' => 'my-id',
    'json' => $jsonData,
    'jsonFieldId' => 'my-credentials-input-field',
    'variables' => $variables,
    'labels' => false,
]);

// the filed where the changed json will be stored
// hide this !!
echo Html::textarea('my-credentials-input-field','', ['id' => 'my-credentials-input-field']);

Output of example above:

alt text

Non keyed version

<?php 
use tonisormisson\jsonform\JsonForm;

$jsonData = '["foo", "bar", "bazinga"]';

echo JsonForm::widget([
    'id' => 'my-id',
    'json' => $jsonData,
    'jsonFieldId' => 'my-credentials-input-field',
    'isKeyed' => false,
]);

// the filed where the changed json will be stored
// hide this !!
echo Html::textarea('my-credentials-input-field','', ['id' => 'my-credentials-input-field']);

alt text