2017 © Pedro Peláez
 

library yii2-basewidgets

Some basic widgets for Yii2

image

peterziv/yii2-basewidgets

Some basic widgets for Yii2

  • Sunday, November 19, 2017
  • by peterziv
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

yii2-basicwidgets

Some simple widgets for Yii2, (*1)

安装 (Installation):

$ composer require "peterziv/yii2-basicwidgets:dev-master"

示例 (Demo):

AccountController:

    public function actionList() {
        $all = [ 11 => [1 => 'A1', 2 => 'A2', 3 => 'A3'], 22 => [1 => 'b1', 2 => 'b2', 3 => 'b3']];
        $type = $_POST['account_type'];
        if (isset($type) && in_array($type, array_keys($all))) {
            $list = $all[$type];
            foreach ($list as $value => $name) {
                $htmlOptions = array('value' => $value);
                echo Html::tag('option', Html::encode($name), $htmlOptions, true);
            }
        }
    }

view:

use peterziv\basicwidgets\ZSelect2Widget;
use yii\widgets\ActiveForm;
use app\models\ModelA;
...

$types =[11=>'a1',22=>'a2'];
$list2 = [1=>'int_b1',2=>'int_b2'];
$model = new ModelA;// new a model if need

// how to use ZSelect2Widget
// dropdownlist #2 will be impacted when changing dropdownlist #1
// the options of dropdownlist #2 is from postUrl account/list
echo ZSelect2Widget::widget([
  'label' => 'Part ZSelect2Widget',
  'formid' => $form->getId(),
  'dropDownList1Name' => 'account_type',
  'postUrl' => 'account/list',
  'initList1' => $types,
  'model' => $model, // it is optional, if id_A is not the property of one model
  'dropDownList2ID' => 'id_A',
  'initList2' => $list2,
]);

...
use peterziv\basicwidgets\ZSelect2InputWidget;
use yii\widgets\ActiveForm;
use app\models\ModelA;
...

$types =[11=>'a1',22=>'a2'];
$list2 = [1=>'int_b1',2=>'int_b2'];
$model = new ModelA;// new a model

// how to use ZSelect2InputWidget
// input will be the same as the value of seleted selection in dropdownlist #2
echo ZSelect2InputWidget::widget([
  'label' => 'Part ZSelect2InputWidget',
  'formid' => $form->getId(),
  'dropDownList1Name' => 'account_type',
  'postUrl' => 'account/list',
  'initList1' => $types,
  'model' => $model, // it is optional, if id_B is not the property of one model
  'dropDownList2ID' => 'id_B',
  'initList2' => $list2,
  'inputModel' => $model,
  'inputID' => 'property_of_ModelA'
]);

...

The Versions

19/11 2017

dev-master

9999999-dev

Some basic widgets for Yii2

  Sources   Download

Apache-2.0

by peter.ziv

extension yii2 widget