PHPackages                             evgeniydev/yii2-form-creator-behavior - 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. [Templating &amp; Views](/categories/templating)
4. /
5. evgeniydev/yii2-form-creator-behavior

ActiveYii2-extension[Templating &amp; Views](/categories/templating)

evgeniydev/yii2-form-creator-behavior
=====================================

Yii2 behavior to create view form

1.0(8y ago)015BSD-3-ClausePHP

Since Dec 1Pushed 8y ago1 watchersCompare

[ Source](https://github.com/jeka-deadline/yii2-FormCreatorBehavior)[ Packagist](https://packagist.org/packages/evgeniydev/yii2-form-creator-behavior)[ Docs](https://github.com/jeka-deadline/yii2-FormCreatorBehavior)[ RSS](/packages/evgeniydev-yii2-form-creator-behavior/feed)WikiDiscussions master Synced yesterday

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

Yii2 form create behavior
-------------------------

[](#yii2-form-create-behavior)

This is behavior which generate view form for methods CREATE and UPDATE.

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

[](#installation)

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

Either run

```
php composer.phar require  evgeniydev/yii2-form-creator-behavior
```

or add

```
"evgeniydev/yii2-form-creator-behavior": "*"

```

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

Basic usage
-----------

[](#basic-usage)

**Model file (app/models/SomeModel.php)**

```
...
use evgeniydev\yii2\behaviors\FormCreatorBehavior
...
class SomeModel extends \yii\base\Model
{
public $field1;
public $field2;
public $field3;
...
public function behaviors()
{
    return [
        ...
        'formBehavior' => [
            'class' => FormCreatorBehavior::className(),
            'attributes' => [
                'field1' => [ //
                    'type' => FormCreatorBehavior::TEXT_INPUT_TYPE,
                    'inputOptions' => [
                        'class' => 'someClass',
                        // other html options
                    ],
                ],
                'field2', // by default generate
                'field3' => [ // generate ...
                    'type' => FormCreatorBehavior::DROPDOWNLIST_TYPE,
                    'items' => ['option1', 'option2'],
                    'inputOptions' => [
                        'prompt' => 'Choose option',
                    ],
                ],
                'field4' => function($form, $model) { // callable function to return view field for this form
                    return $form->field($model)
                }
                // other fields
            ],
        ]
        ...
    ];
}
```

**Controller file (app/controllers/SomeController.php)**

```
use app\models\SomeModel.php
...
public function actionCreate()
{
    $model = new SomeModel();
    if ($model->load(\Yii::$app->request->post()) && $model->save()) {
        //  model save
    }

    return $this->render('form', [
        'model' => $model,
    ]);
}

public function actionUpdate($id)
{
    $model = SomeModel::findOne($id);

    if (!$model) {
        // throw not found
    }
    if ($model->load(\Yii::$app->request->post()) && $model->save()) {
        //  model update
    }

    return $this->render('form', [
        'model' => $model,
    ]);
}
...
```

**View file (app/views/some/form.php)**

```

```

Other field types
-----------------

[](#other-field-types)

**Checkbox**

```
'field1' => [
    'type' => FormCreatorBehavior::CHECKBOX_TYPE,
    'inputOptions' => [
        'class' => 'someClass',
        // other html options
    ],
],
```

**Checkbox list**

```
'field1' => [
    'type' => FormCreatorBehavior::CHECKBOXLIST_TYPE,
    'items' => ['check1', 'check2'],
    'inputOptions' => [
        'class' => 'someClass',
        // other html options
    ],
],
```

**Widget**

```
'field1' => [
    'type' => FormCreatorBehavior::WIDGET_TYPE,
    'widgetClass' => '' // widget class name
    'widgetOptions' => [...], // widget options
],
```

**List box**

```
'field1' => [
    'type' => FormCreatorBehavior::LISTBOX_TYPE,
    'items' => ['check1', 'check2'],
    'inputOptions' => [
        'class' => 'someClass',
        // other html options
    ],
],
```

**Input with custom type**

```
'field1' => [ //
    'type' => FormCreatorBehavior::INPUT_TYPE,
    'inputType' => 'tel',
    'inputOptions' => [
        'class' => 'someClass',
        // other html options
    ],
],
```

Full list constants types
-------------------------

[](#full-list-constants-types)

- ***TEXT\_INPUT\_TYPE*** - text input
- ***TEXTAREA\_TYPE*** - textarea
- ***CHECKBOX\_TYPE*** - checkbox
- ***DROPDOWNLIST\_TYPE*** - dropdownlist
- ***WIDGET\_TYPE*** - widget
- ***INPUT\_TYPE*** - input with custom type
- ***HIDDEN\_INPUT\_TYPE*** - hidden input
- ***FILE\_INPUT\_TYPE*** - file input
- ***PASSWORD\_INPUT\_TYPE*** - password input
- ***RADIO\_TYPE*** - radio input
- ***RADIOLIST\_TYPE*** - radio list
- ***CHECKBOXLIST\_TYPE*** - checkboxe list
- ***LISTBOX\_TYPE*** - list box

Other configuration
-------------------

[](#other-configuration)

**Input with callable function*****function template: function($form, $model){ return ...; }***

```
'field1' => function($form, $model) { // callable function
    return $form->field($model, 'field1');
},
```

**Label**

```
'field1' => [
    'type' => FormCreatorBehavior::TEXT_INPUT_TYPE,
    'label' => 'Some label', // or false, if want not show label
    ...
],
```

**Hint (short form)**

```
'field1' => [
    'type' => FormCreatorBehavior::TEXT_INPUT_TYPE,
    'hint' => 'Some hint',
    ...
],
```

or full form

```
'field1' => [
    'type' => FormCreatorBehavior::TEXT_INPUT_TYPE,
    'hint' => [
        'content' => 'Some content', // hint content
        'options' => [...], // hint options
    ],
    ...
],
```

**Form configuration**

```
'class' => FormCreatorBehavior::className(),
'attributes' => [...], // array attributes
'formOptions' => [
    'options' => [
        'enctype' => 'multipart/form-data'
    ],
    'id' => 'Some id',
    ... // other \yii\widgets\ActiveForm widget options
]
```

**Template view**

```
'class' => FormCreatorBehavior::className(),
'attributes' => [...], // array attributes
'template' => '{items}{beginBlockButtons}{submitButton}{cancelButton}{endBlockButtons}', // template view
```

```
{items} - elements of form
{beginBlockButtons} - open tag for block with form buttons
{submitButton} - submit form button
{cancelButton} - cancel form button
{endBlockButtons} - end tag for block with buttons

```

**Submit button options**

```
'class' => FormCreatorBehavior::className(),
'attributes' => [...], // array attributes
'submitButtonOptions' => [
    'createButtonOptions' => [ // create button options
        'title' => 'Create', // text create button
        'tag' => 'input', // tag create button (input|button)
        'htmlOptions' => [...], // create button html options
    ],
    'updateButtonOptions' => [
        'title' => 'Update', // text update button
        'tag' => 'input', // tag update button (input|button)
        'htmlOptions' => [...], // update button html options
    ],
],
```

**Cancel button options**

```
'class' => FormCreatorBehavior::className(),
'attributes' => [...], // array attributes
'cancelButtonOptions' => [
    'show' => true, // true or false, show cancel button
    'title' => 'Cancel', // text cancel button
    'action' => ['index'], // url to go cancel operation, by default is action index
    'htmlOptions' => [...], // cancel button html options
],
```

**Wrapper block buttons form options**

```
'class' => FormCreatorBehavior::className(),
'attributes' => [...], // array attributes
'wrapperBlockButtonsOptions' => [
    'tag' => 'div', // tag name wrapper buttons block or false
    'htmlOptions' => [...], // cancel button html options
],
```

**Tabs**

```
'class' => FormCreatorBehavior::className(),
'tabOptions' => [ // tab options
    'widgetName' => '...', // tab widget name, default is \yii\bootstrap\Tabs
    'widgetOptions' => [
        'keyNameContentField' => '...', // key name tab content field, default 'content'
        // ... other some widget options
    ],
    'tabs' => [
        [ // tab 1
            'tabAttributes' => ['someField1', 'someField2', ...], // list attributes on this tab,
            'content' => '{items}', // template of content tab, {items} to be replaced by fields attribues on this tab, 'content' if
                       // keyNameContentField = 'content', if keyNameContentField not equal 'content', then key 'content' key must be other
            // .. other tab options for this widget tab, example \yii\bootstrap\Tabs: 'title' => 'Some title',
        ],
        [ // tab 2
            'tabAttributes' => ['someField3', 'someField4', ...], // list attributes on this tab,
            // .. other tab options for this widget tab, example \yii\bootstrap\Tabs: 'title' => 'Some title',
        ],
        // ... other tabs
    ],
],
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

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

Unknown

Total

1

Last Release

3085d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/558b8671c661649c85a845805175fb8dae0c9d8f850698c86b5710de8da6dcc3?d=identicon)[evgeniy.bublik](/maintainers/evgeniy.bublik)

---

Top Contributors

[![evgeniy-bublik](https://avatars.githubusercontent.com/u/11794472?v=4)](https://github.com/evgeniy-bublik "evgeniy-bublik (12 commits)")

---

Tags

yii2Behavior

### Embed Badge

![Health badge](/badges/evgeniydev-yii2-form-creator-behavior/health.svg)

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.6k](/packages/craftcms-cms)[ogheo/yii2-htmlcompress

Compress HTML output into a single line

20184.4k1](/packages/ogheo-yii2-htmlcompress)[marqu3s/yii2-summernote

Yii2 Summernote widget. Super simple WYSIWYG editor on Bootstrap

1691.6k8](/packages/marqu3s-yii2-summernote)[zxbodya/yii2-tinymce

Yii2 extension to use TinyMce with Compressor and FileManager

1732.1k3](/packages/zxbodya-yii2-tinymce)

PHPackages © 2026

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