PHPackages                             quanzo/yii2-fields - 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. quanzo/yii2-fields

ActiveLibrary

quanzo/yii2-fields
==================

1.0.0(6y ago)011MITPHPPHP &gt;=7.0

Since Sep 5Pushed 6y ago1 watchersCompare

[ Source](https://github.com/quanzo/yii2-fields)[ Packagist](https://packagist.org/packages/quanzo/yii2-fields)[ RSS](/packages/quanzo-yii2-fields/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (1)

Fields for Yii2
===============

[](#fields-for-yii2)

Why
---

[](#why)

Representation of a form field as a class. For universal configuration of a model or form as an array of parameters.

\-------------------------------------------

Представление поля формы в виде класса. Для универсальной настройки модели или формы в виде массива параметров.

```
$arFields = [
    'metaTitle' => [
        'class' => '\x51\yii2\classes\fields\Input',
        'title' => 'Title',
        'name' => 'meta_title_field',
        'value' => '',
        'options' => [
            'class' => 'form-control',
        ],
        'rules' => [
            ['required'] // rule without field name
        ],
    ],
    'metaDescription' => [
        'class' => '\x51\yii2\classes\fields\Input',
        'title' => 'Description',
        'name' => 'meta_description_field',
        'value' => '',
        'options' => [
            'class' => 'form-control',
        ],
    ]
];

$arModelRules = [
    ['metaDescription', 'require'] // rule with field name/names
];

$fieldsModel = new x51\yii2\classes\fields\models\FieldsModel($arFields, $arModelRules);

// set function for save data
$fieldsModel->funcSave(function (array $arData) {/* save model data. arData - array fieldname=>field_value_for_save  */});
// available
if ($fieldsModel->save()) {
...
}

// output form
echo $fieldsModel->render($formName);

```

Данные, которые предоставляет модель (поле, заданное классом) и данные для сохранения, могут быть различными.

Например, поле для ввода нескольких текстовых строк. Предоставляет данные в виде массива, а данные для сохранения - это сериализованная строка.

\-------------------------------------------

The data that the model provides (the field specified by the class) and the data to be stored can be different.

For example, a field for entering several text lines. Provides data as an array, and data to save is a serialized string.

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

[](#installation)

1. Copy to the folder with modules and connect *autoload.php*
2. Or use composer: add to the *require* section of the project `"quanzo/yii2-fields": "*"` or `composer require "quanzo/yii2-fields"`

Events
------

[](#events)

### In field

[](#in-field)

```
$arFields = [
    'metaTitle' => [
        'class' => '\x51\yii2\classes\fields\Input',
        'title' => 'Title',
        'name' => 'meta_title_field',
        'value' => '',
        'options' => [
            'class' => 'form-control',
        ],
        'rules' => [
            ['required'] // rule without field name
        ],
        'on '.\x51\yii2\classes\fields\Base::EVENT_BEFORE_RENDER => function ($event) {
    if ($event->field->name == 'meta_title_field') {
        $event->title = 'New title';
    }
}
    ]
];

```

idEvent class`\x51\yii2\classes\fields\Base::EVENT_BEFORE_RENDER`will be called before forming html`x51\yii2\classes\fields\events\BeforeRenderFieldEvent`**Changing data in an event will affect the result.**### In model

[](#in-model)

`x51\yii2\classes\fields\models\FieldsModel::EVENT_BEFORE_SAVE``events\SaveValuesEvent`Changing property **attributes** in an event will affect the result.`x51\yii2\classes\fields\models\FieldsModel::EVENT_BEFORE_LOAD_FIELD``events\LoadValueEvent`Called in $model-&gt;load. Called when each data field is processed. Affecting results.`x51\yii2\classes\fields\models\FieldsModel::EVENT_AFTER_LOAD``events\LoadValueEvent`Called in $model-&gt;load. After the load is complete.`x51\yii2\classes\fields\models\FieldsModel::EVENT_BEFORE_RENDER``events\RenderFormEvent`Called in $model-&gt;render. Affects the result.`x51\yii2\classes\fields\models\FieldsModel::EVENT_AFTER_RENDER``events\RenderFormEvent`Called in $model-&gt;render. Affects the result.```
$fieldsModel->on(FieldsModel::EVENT_BEFORE_RENDER, function ($event) {
    $event->out = '';
});
$fieldsModel->on(FieldsModel::EVENT_AFTER_RENDER, function ($event) {
    $event->out .= '';
});

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

2438d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10706162?v=4)[quanzo](/maintainers/quanzo)[@quanzo](https://github.com/quanzo)

---

Top Contributors

[![quanzo](https://avatars.githubusercontent.com/u/10706162?v=4)](https://github.com/quanzo "quanzo (3 commits)")

---

Tags

yii2yii

### Embed Badge

![Health badge](/badges/quanzo-yii2-fields/health.svg)

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

###  Alternatives

[brussens/yii2-maintenance-mode

Maintenance mode component for Yii framework 2.x.x version.

78256.3k5](/packages/brussens-yii2-maintenance-mode)

PHPackages © 2026

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