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

ActiveYii2-extension

sorokinmedia/yii2-custom-fields
===============================

Custom fields(json) component for Yii2

115PHP

Since Sep 23Pushed 7y ago5 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

yii2-custom-fields
==================

[](#yii2-custom-fields)

[![Total Downloads](https://camo.githubusercontent.com/ce8c1603c2204010d85784c5cf5424fec4a8eb3026c9ff299d9bf541fdea0962/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736f726f6b696e6d656469612f796969322d637573746f6d2d6669656c64732e737667)](https://packagist.org/packages/sorokinmedia/yii2-custom-fields)

---

Sorokin.Media repository

---

Компонент для работы с `custom_fields` внутри любой AR модели. Работа с json-полем в БД.

---

### Описание модели CustomFieldModel (кастомное поле)

[](#описание-модели-customfieldmodel-кастомное-поле)

атрибуты:

- `id` - id, уникальный итератор - `integer`
- `name` - название поля - `string(255)`
- `value` - значение поля - `string`
- `number` - порядковый номер для Drag'n'Drop - `integer`

### Общий принцип работы

[](#общий-принцип-работы)

В атрибут AR модели пишем массив объектов `CustomFieldModel`, в `json` формате. Вся работа с этим полем организована в `CustomFieldHelper`.

#### Описание хелпера CustomFieldHelper

[](#описание-хелпера-customfieldhelper)

Содержит ряд вспомогательных методов для работы с атрибутом `custom_fields`. Все методы в хелпере статические.

- `public static function getMaxId(array $custom_fields = null) : int` - получает текущий максимальный `ID` в массиве полей. Если атрибут `custom_fields` пуст(`null`), вернет `0`.
- `public static function addCustomFields(array $custom_fields_array, array $custom_fields = null) : array` - добавляет массив кастомных полей в атрибут `custom_fields`. Автоматически проставляет `id` внутри моделей `CustomFieldModel`. Первый параметр - массив полей, которые нужно добавить. Вторым параметров принимает уже существующие поля, к которым нужно добавить поля из первого параметра.
- `public static function updateCustomField(array $custom_field_array, array $custom_fields) : array` - обновляет поле внутри массива полей `custom_fields`. Ищет по `id` элемента и заменяет. Первый параметр - новое поле, второй параметр - уже существующие поля.
- `public static function deleteCustomField(int $id, array $custom_fields) : array` - удаляет модель `CustomFieldModel` внутри массива полей `custom_fields`. Ищет по `id`. Первый параметр - `id` элемента, который нужно удалить, второй параметр - уже существующие поля.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity42

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6071315?v=4)[Ruslan Gilyazetdinov](/maintainers/Ma3oBblu)[@Ma3oBblu](https://github.com/Ma3oBblu)

---

Top Contributors

[![Ma3oBblu](https://avatars.githubusercontent.com/u/6071315?v=4)](https://github.com/Ma3oBblu "Ma3oBblu (5 commits)")

### Embed Badge

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

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

PHPackages © 2026

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