tonisormisson/yii2-json-form 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tonisormisson/yii2-json-form

最新稳定版本:1.5.3

Composer 安装命令:

composer require tonisormisson/yii2-json-form

包简介

The JSON form view widget for yii2

README 文档

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

Example usage Select2


// ######################### example 3 select
$jsonData = '{"select2":3}';
$variables = [
    'select2'=>[
        'label' => Yii::t('app','A select 2 example'),
        'type' => JsonForm::TYPE_SELECT2,
        'select' => [
            1 => "one",
            2 => "two",
            3 => "three"
        ],
        'options' => ['placeholder' => 'Select a number ...'],
        'pluginOptions' => [
            'allowClear' => true
        ]
    ],
];

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

alt text

统计信息

  • 总下载量: 5.21k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2018-02-01