2017 © Pedro Peláez
 

yii2-extension yii2-depdrop

The dependent dropdown widget for the Yii framework 2

image

zrk4939/yii2-depdrop

The dependent dropdown widget for the Yii framework 2

  • Tuesday, March 20, 2018
  • by zrk4939
  • Repository
  • 0 Watchers
  • 0 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

yii2-depdrop

A Dependent DropDown widget for the Yii2 framework, (*1)

Installation

Add, (*2)

"zrk4939/yii2-depdrop": "@dev"

to the require section of your composer.json file and execute composer update., (*3)

Usage

Widget

<?php
echo $form->field($model, 'attribute')->widget(\zrk4939\widgets\depdrop\DepDrop::className(), [
    'placeholder' => 'Выбрать из списка...',
    'depends' => ['id-dependent-field'],
    'url' => \yii\helpers\Url::to(['/ajax/get', 'selected' => $model->getAttribute('attribute')]),
])
?>

Controller

<?php
public function actionGet()
{
    Yii::$app->response->format = Response::FORMAT_JSON;

    $result = [
        'output' => [],
        'selected' => Yii::$app->request->get('selected')
    ];

    if (Yii::$app->request->isPost) {
        $post = Yii::$app->request->post('depdrop_all_params');
        $query = SomeModel::find()
                ->andWhere(['attribute' => $post['attribute']]);

        foreach ($query->all() as $model) {
            $result['output'][] = [
                'id' => $model->getAttribute('id'),
                'name' => $model->getAttribute('name'),
            ];
        }
    }

    return $result;
}
?>

The Versions

20/03 2018

dev-master

9999999-dev

The dependent dropdown widget for the Yii framework 2

  Sources   Download

Unlicense BSD 3-Clause

by Ilya Youshketov

yii2 dropdown dependent dropdown

20/03 2018

1.0.1

1.0.1.0

The dependent dropdown widget for the Yii framework 2

  Sources   Download

Unlicense

by Ilya Youshketov

yii2 dropdown dependent dropdown

20/03 2018

1.0.0

1.0.0.0

The dependent dropdown widget for the Yii framework 2

  Sources   Download

Unlicense

by Ilya Youshketov

yii2 dropdown dependent dropdown