PHPackages                             pavlinter/yii2-multifields - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. pavlinter/yii2-multifields

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

pavlinter/yii2-multifields
==========================

Yii2: Multi dinamic fields

v1.0.2(10y ago)010321BSD 3-ClauseJavaScript

Since Jan 13Pushed 10y ago2 watchersCompare

[ Source](https://github.com/pavlinter/yii2-multifields)[ Packagist](https://packagist.org/packages/pavlinter/yii2-multifields)[ RSS](/packages/pavlinter-yii2-multifields/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (1)Versions (4)Used By (1)

Yii2 Multifields
================

[](#yii2-multifields)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist pavlinter/yii2-multifields "*"

```

or add

```
"pavlinter/yii2-multifields": "*"

```

to the require section of your `composer.json` file.

Example
-------

[](#example)

Controller

```

use pavlinter\multifields\ModelHelper;
use yii\web\Response;

...

public function actionCreate()
{
    $model = new Product();
    $options = [new ProductOption(['scenario' => 'multiFields'])];

    if(Yii::$app->request->isPost) {

        $loaded = $model->load(Yii::$app->request->post());
        $loaded = ModelHelper::load($options) && $loaded;

        if ($loaded) {

            if (ModelHelper::validate([$model, $options])) {
                $model->save(false);
                $newId = [];
                foreach ($options as $oldId => $option) {
                    $option->id_product = $model->id;
                    $option->save(false);
                    ModelHelper::ajaxChangeField($newId, $option, 'name', $oldId);
                    ModelHelper::ajaxChangeField($newId, $option, 'value', $oldId);
                }
                if (Yii::$app->request->isAjax) {
                    Yii::$app->response->format = Response::FORMAT_JSON;
                    return ['r' => 1, 'newId' => $newId];
                } else {
                    return $this->redirect(['index']);
                }
            } else {
                if (Yii::$app->request->isAjax) {
                    Yii::$app->response->format = Response::FORMAT_JSON;
                    $errors = ModelHelper::ajaxErrors([$model, $options]);
                    return ['r' => 0, 'errors' => $errors];
                }
            }
        }
    }
    return $this->render('create', [
        'model' => $model,
        'options' => $options,
    ]);
}
public function actionUpdate($id)
{
    $model = Product::findOne($id);
    $options = ProductOption::find()->where(['id_product' => $id])->indexBy('id')->all();
    if (empty($options)) {
        $options[] = new ProductOption(['scenario' => 'multiFields']);
    } else {
        foreach ($options as $option) {
            $option->scenario = 'multiFields';
        }
    }

    if(Yii::$app->request->isPost) {

        $loaded = $model->load(Yii::$app->request->post());
        $loaded = ModelHelper::load($options) && $loaded;

        if ($loaded) {

            if (ModelHelper::validate([$model, $options])) {
                $model->save(false);
                $newId = [];
                foreach ($options as $oldId => $option) {
                    $option->id_product = $model->id;
                    $option->save(false);
                    ModelHelper::ajaxChangeField($newId, $option, 'name', $oldId);
                    ModelHelper::ajaxChangeField($newId, $option, 'value', $oldId);
                }

                if (Yii::$app->request->isAjax) {
                    Yii::$app->response->format = Response::FORMAT_JSON;
                    return ['r' => 1, 'newId' => $newId];
                } else {
                    return $this->redirect(['index']);
                }
            } else {
                if (Yii::$app->request->isAjax) {
                    Yii::$app->response->format = Response::FORMAT_JSON;
                    $errors = ModelHelper::ajaxErrors([$model, $options]);
                    return ['r' => 0, 'errors' => $errors];
                }
            }
        }
    }

    return $this->render('update', [
        'model' => $model,
        'options' => $options,
    ]);

}
public function actionDeleteOption()
{
    $id = Yii::$app->request->post('id');
    $model = ProductOption::findOne($id);
    if ($model !== null) {
        $model->delete();
    }
    Yii::$app->response->format = Response::FORMAT_JSON;
    return ['r' => 1];
}

```

View

```
use pavlinter\multifields\MultiFields;

...

```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~138 days

Total

3

Last Release

3860d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/aa81148f518734b069ef57f90038de857b4022a2a1b8d59a0f75ccada1747409?d=identicon)[pavlinter](/maintainers/pavlinter)

---

Top Contributors

[![pavlinter](https://avatars.githubusercontent.com/u/6838002?v=4)](https://github.com/pavlinter "pavlinter (46 commits)")

---

Tags

yii2multidinamicmultiinputmultifields

### Embed Badge

![Health badge](/badges/pavlinter-yii2-multifields/health.svg)

```
[![Health](https://phpackages.com/badges/pavlinter-yii2-multifields/health.svg)](https://phpackages.com/packages/pavlinter-yii2-multifields)
```

###  Alternatives

[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)[richardfan1126/yii2-js-register

Yii2 widget to register JS into view

1357.2k7](/packages/richardfan1126-yii2-js-register)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
