PHPackages                             flaviovs/yii2-form - 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. flaviovs/yii2-form

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

flaviovs/yii2-form
==================

Composite models (a.k.a forms) for Yii2

0.0.5(7y ago)1962MITPHPPHP &gt;=5.4.0

Since Apr 17Pushed 7y ago1 watchersCompare

[ Source](https://github.com/flaviovs/yii2-form)[ Packagist](https://packagist.org/packages/flaviovs/yii2-form)[ RSS](/packages/flaviovs-yii2-form/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (6)Used By (0)

Composite models (a.k.a forms) for Yii2
=======================================

[](#composite-models-aka-forms-for-yii2)

The use case
------------

[](#the-use-case)

You need form input for separate model objects in your application.

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

[](#installation)

```
$ composer require flaviovs/yii2-form
```

How to
------

[](#how-to)

1. Create your form model. Add composing models as normal attributes:

    ```
    class MyForm extends fv\yii\form\Model
    {
    	/** @var \app\models\Post */
    	public $post;

    	/** @var \app\models\Comment */
    	public $comment;
    }
    ```
2. Add the `modelAttributes()` function, which indicates which form attributes contain models to be loaded on submission:

    ```
    protected function modelAttributes()
    {
    	return ['post', 'comment'];
    }
    ```
3. Add validation rules for the models:

    ```
    protected function rules()
    {
        return [
            [$this->modelAttributes(), 'safe'];
        ];
    }
    ```
4. Add input controls to your views as you normally would. Just remember to reference model attributes of the form, instead of the form model itself.

    ```
    /** @var \fv\yii\form\Model $model */

    $form = ActiveForm::begin();

    echo $form->field($model->post, 'title');
    echo $form->field($model->comment, 'body');

    ActiveForm::End();
    ```
5. Process the form as you normally do:

    ```
    $model = new MyForm([
    	'post' => new Post(),
    	'comment' => new Comment(),
    ]);
    if ($model->load(\Yii::$app->request->post()) && $model->validate()) {
    	$model->post->save();
    	$model->comment->save();
    }
    ```

Support
-------

[](#support)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

Every ~6 days

Total

5

Last Release

2559d ago

### Community

Maintainers

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

---

Top Contributors

[![flaviovs](https://avatars.githubusercontent.com/u/1832699?v=4)](https://github.com/flaviovs "flaviovs (8 commits)")

### Embed Badge

![Health badge](/badges/flaviovs-yii2-form/health.svg)

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

###  Alternatives

[stevegrunwell/one-time-callbacks

Enable WordPress actions and filter callbacks to be called exactly once.

6847.4k](/packages/stevegrunwell-one-time-callbacks)[gerardojbaez/messenger

Messenger functionality for Laravel 5.2.

738.5k](/packages/gerardojbaez-messenger)[cubear/finder

Finder is a Drupal 8 module to help users find services which meet their criteria

404.2k](/packages/cubear-finder)

PHPackages © 2026

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