PHPackages                             kartik-v/yii2-builder - 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. kartik-v/yii2-builder

ActiveYii2-extension

kartik-v/yii2-builder
=====================

Build forms (single-row or multi-row/tabular) easily for Yii Framework 2.0

v1.6.9(4y ago)1011.1M—6.2%50[3 issues](https://github.com/kartik-v/yii2-builder/issues)20BSD-3-ClausePHP

Since Jun 11Pushed 4y ago15 watchersCompare

[ Source](https://github.com/kartik-v/yii2-builder)[ Packagist](https://packagist.org/packages/kartik-v/yii2-builder)[ Docs](https://github.com/kartik-v/yii2-builder)[ Fund](https://opencollective.com/kartik-v)[ RSS](/packages/kartik-v-yii2-builder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (17)Used By (20)

 [ ![Krajee Logo](https://camo.githubusercontent.com/4addfbb3869c3fc7d79befea4f06d9cf3655a686fb503df0da1d725859cfdef9/687474703a2f2f6b617274696b2d762e6769746875622e696f2f626f6f7473747261702d66696c65696e7075742d73616d706c65732f73616d706c65732f6b72616a65652d6c6f676f2d622e706e67) ](http://demos.krajee.com "Krajee Demos")
 yii2-builder ---

 [![Donate](https://camo.githubusercontent.com/0336bc43d88554a3f2d6c74dddf312bc2c65c2eacca70d83ae40f5567098d00e/68747470733a2f2f6b617274696b2d762e6769746875622e696f2f626f6f7473747261702d66696c65696e7075742d73616d706c65732f73616d706c65732f646f6e6174652e706e67)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DTP3NZQ6G2AYU "Donate via Paypal") [![kartikv](https://camo.githubusercontent.com/0cf29a542375e1a46e84d8bf5805a4e5c0a6ee98b6547ccdc0c55eed49d99c69/68747470733a2f2f63646e2e6275796d6561636f666665652e636f6d2f627574746f6e732f76322f64656661756c742d79656c6c6f772e706e67)](https://www.buymeacoffee.com/kartikv "Buy me a coffee")
===============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#------------------------yii2-builder------------------)

[![Latest Stable Version](https://camo.githubusercontent.com/46c79ab2cc176e5642a5a6b2031d8b7118f4d9911570c5eecdf352ce4dcb453f/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d6275696c6465722f762f737461626c65)](https://packagist.org/packages/kartik-v/yii2-builder)[![Latest Unstable Version](https://camo.githubusercontent.com/758dbcb7ca93355cf22ed248347c7cf557c251e7c41f55121293928a52f516bb/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d6275696c6465722f762f756e737461626c65)](https://packagist.org/packages/kartik-v/yii2-builder)[![License](https://camo.githubusercontent.com/40d87ab12d7ca696e2677afeb99dd5054a64298fa43cd72b3a8c600545ba48d5/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d6275696c6465722f6c6963656e7365)](https://packagist.org/packages/kartik-v/yii2-builder)[![Total Downloads](https://camo.githubusercontent.com/246fe90b5424f7fbcea723863448a79fc9f84e6411bfbcdc7136b8a5a5eb62c6/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d6275696c6465722f646f776e6c6f616473)](https://packagist.org/packages/kartik-v/yii2-builder)[![Monthly Downloads](https://camo.githubusercontent.com/6dfaf2f22f9db9b02bf6c43300abf3cd39edb487794598a5b2d537c7879fdc6a/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d6275696c6465722f642f6d6f6e74686c79)](https://packagist.org/packages/kartik-v/yii2-builder)[![Daily Downloads](https://camo.githubusercontent.com/56a40d71035f8bbcccf836903705bfa3c697b919b2fcdbb30c78e7b431ae9121/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d6275696c6465722f642f6461696c79)](https://packagist.org/packages/kartik-v/yii2-builder)

A form builder extension that allows you to build both single view and multi-view/tabular forms for Yii Framework 2.0. The extension contains these widgets:

- Form
- FormGrid
- TabularForm

> NOTE: Check the [composer.json](https://github.com/kartik-v/yii2-builder/blob/master/composer.json) for this extension's requirements and dependencies.

Latest Release
--------------

[](#latest-release)

Refer the [CHANGE LOG](https://github.com/kartik-v/yii2-builder/blob/master/CHANGE.md) for details on changes to various releases.

Docs &amp; Demo
---------------

[](#docs--demo)

You can see detailed [docs &amp; demos](http://demos.krajee.com/builder-details/form) and the API [code documentation](https://docs.krajee.com/kartik-builder-form) on usage of the extension.

Form
----

[](#form)

`\kartik\builder\Form`

The Form Builder widget allows you to build a form through a configuration array. Key features available:

- Configure your form fields from a model extending `yii\base\model` or `yii\db\ActiveRecord`.
- Ability to support various Bootstrap form layouts. Uses the advanced [`kartik\widgets\ActiveForm`](http://demos.krajee.com/widget-details/active-form).
- Use Bootstrap column/builder layout styling by just supplying `columns` property.
- Build complex layouts (for example single, double, or multi columns in the same layout) - by reusing the widget for building your attributes.
- Tweak ActiveForm defaults to control field options, styles, templates, and layouts.
- Configure your own hints to display below each active field attribute.
- Various Bootstrap styling features are available by default. However, one can easily customize and theme it to one's liking using any CSS framework.
- Supports and renders HTML input types (uses [`kartik\widgets\ActiveField`](http://demos.krajee.com/widget-details/active-field)) including input widgets and more:
    - `INPUT_TEXT` or `textInput`
    - `INPUT_TEXTAREA` or `textarea`
    - `INPUT_PASSWORD` or `passwordInput`
    - `INPUT_DROPDOWN_LIST` or `dropdownList`
    - `INPUT_LIST_BOX` or `listBox`
    - `INPUT_CHECKBOX` or `checkbox`
    - `INPUT_RADIO` or `radio`
    - `INPUT_CHECKBOX_LIST` or `checkboxList`
    - `INPUT_CHECKBOX_BUTTON_GROUP` or `checkboxList`
    - `INPUT_RADIO_LIST` or `radioList`
    - `INPUT_MULTISELECT` or `multiselect`
    - `INPUT_FILE` or `fileInput`
    - `INPUT_HTML5` or `input`
    - `INPUT_WIDGET` or `widget`
    - `INPUT_HIDDEN` or `hiddenInput`
    - `INPUT_STATIC` or `staticInput`
    - `INPUT_HIDDEN_STATIC` or `hiddenStaticInput`
    - `INPUT_RAW` or `raw` (any free text or html markup)

FormGrid
--------

[](#formgrid)

`\kartik\builder\FormGrid`

Create bootstrap grid layouts in a snap. The Form Grid Builder widget offers an easy way to configure your form inputs as a bootstrap grid layout and a single array configuration. It basically uses multiple instances of the `\kartik\builder\Form` widget above to generate this grid. One needs to just setup the rows for the grid, where each row will be an array configuration as needed by the `Form` widget. However, most of the common settings like `model`, `form`, `columns` etc. can be defaulted at `FormGrid` widget level.

Tabular Form
------------

[](#tabular-form)

`kartik\builder\TabularForm`

The tabular form allows you to update information from multiple models (typically used in master-detail forms). Key features

- Supports all input types as mentioned in the `Form` builder widget
- The widget works like a Yii GridView and uses an ActiveDataProvider to read the models information.
- Supports features of the builderview like pagination and sorting.
- Allows you to highlight and select table rows
- Allows you to add and configure action buttons for each row.
- Configure your own hints to display below each active field attribute.
- Various Bootstrap styling features are available by default. However, one can easily customize and theme it to one's liking using any CSS framework.
- Advanced table styling, columns, and layout configuration by using the features available in the [`kartik\builder\GridView`](http://demos.krajee.com/grid) and the [`kartik\widgets\ActiveForm`](http://demos.krajee.com/builder) widget.
- One can easily read and manage the tabular input data using the `loadMultiple` and `validateMultiple` functions in `yii\base\Model`.

> NOTE: The TabularForm widget depends on and uses the [yii2-grid](http://demos.krajee.com/grid) module. Hence, the `gridview` module needs to be setup in your Yii configuration file.

```
'modules' => [
   'gridview' =>  [
        'class' => '\kartik\grid\Module'
    ]
];
```

> IMPORTANT: You must follow one of the two options to setup your DataProvider or your columns to ensure primary key for each record is properly identified.

- **Option 1 (preferred):** Setup your dataProvider query to use `indexBy` method to index your records by primary key. For example:

```
$query = Model::find()->indexBy('id'); // where `id` is your primary key

$dataProvider = new ActiveDataProvider([
    'query' => $query,
]);
```

- **Option 2 (alternate):** You can setup the primary key attribute as one of your columns with a form input type (and hide if needed) - so that the models are appropriately updated via `loadMultiple` method (even if you reorder or sort the columns). You must also set this attribute to be `safe` in your model validation rules. This is been depicted in the example below.

```
'attributes'=>[
    'id'=>[ // primary key attribute
        'type'=>TabularForm::INPUT_HIDDEN,
        'columnOptions'=>['hidden'=>true]
    ],
 ]
```

### Demo

[](#demo)

You can see detailed [documentation](http://demos.krajee.com/builder) on usage of the extension.

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

[](#installation)

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

> Note: You must set the `minimum-stability` to `dev` in the **composer.json** file in your application root folder before installation of this extension.

Either run

```
$ php composer.phar require kartik-v/yii2-builder "@dev"

```

or add

```
"kartik-v/yii2-builder": "@dev"

```

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

Usage
-----

[](#usage)

### Form

[](#form-1)

```
use kartik\builder\Form;
$form = ActiveForm::begin();
echo Form::widget([
    'model' => $model,
    'form' => $form,
    'columns' => 2,
    'attributes' => [
        'username' => ['type'=>Form::INPUT_TEXT, 'options'=>['placeholder'=>'Enter username...']],
        'password' => ['type'=>Form::INPUT_PASSWORD, 'options'=>['placeholder'=>'Enter password...']],
        'rememberMe' => ['type'=>Form::INPUT_CHECKBOX],
    ]
]);
ActiveForm::end();
```

### FormGrid

[](#formgrid-1)

```
use kartik\builder\Form;
use kartik\builder\FormGrid;
$form = ActiveForm::begin();
echo FormGrid::widget([
    'model' => $model,
    'form' => $form,
    'autoGenerateColumns' => true,
    'rows' => [
        [
            'attributes' => [
                'username' => ['type'=>Form::INPUT_TEXT, 'options'=>['placeholder'=>'Enter username...']],
                'password' => ['type'=>Form::INPUT_PASSWORD, 'options'=>['placeholder'=>'Enter password...']],
                'rememberMe' => ['type'=>Form::INPUT_CHECKBOX],
            ],
        ],
        [
            'attributes' => [
                'first_name' => ['type'=>Form::INPUT_TEXT, 'options'=>['placeholder'=>'Enter first name...']],
                'last_name' => ['type'=>Form::INPUT_TEXT, 'options'=>['placeholder'=>'Enter last name...']],
            ]
        ]
    ]
]);
ActiveForm::end();
```

### TabularForm

[](#tabularform)

```
use kartik\builder\TabularForm;
$form = ActiveForm::begin();
echo TabularForm::widget([
    'bsVersion' => '4.x',
    'form' => $form,
    'dataProvider' => $dataProvider,
    'attributes' => [
        'name' => ['type' => TabularForm::INPUT_TEXT],
        'color' => [
            'type' => TabularForm::INPUT_WIDGET,
            'widgetClass' => \kartik\widgets\ColorInput::classname()
        ],
        'author_id' => [
            'type' => TabularForm::INPUT_DROPDOWN_LIST,
            'items'=>ArrayHelper::map(Author::find()->orderBy('name')->asArray()->all(), 'id', 'name')
        ],
        'buy_amount' => [
            'type' => TabularForm::INPUT_TEXT,
            'options'=>['class'=>'form-control text-right'],
            'columnOptions'=>['hAlign'=>GridView::ALIGN_RIGHT]
        ],
        'sell_amount' => [
            'type' => TabularForm::INPUT_STATIC,
            'columnOptions'=>['hAlign'=>GridView::ALIGN_RIGHT]
        ],
    ],
    'gridSettings' => [
        'floatHeader' => true,
        'panel' => [
            'heading' => ' Manage Books',
            'type' => GridView::TYPE_PRIMARY,
            'after'=>
                Html::a(
                    ' Add New',
                    $createUrl,
                    ['class'=>'btn btn-success']
                ) . '&nbsp;' .
                Html::a(
                    ' Delete',
                    $deleteUrl,
                    ['class'=>'btn btn-danger']
                ) . '&nbsp;' .
                Html::submitButton(
                    ' Save',
                    ['class'=>'btn btn-primary']
                )
        ]
    ]
]);
ActiveForm::end();
```

License
-------

[](#license)

**yii2-builder** is released under the BSD-3-Clause License. See the bundled `LICENSE.md` for details.

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity56

Moderate usage in the ecosystem

Community36

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 94.2% 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 ~184 days

Recently: every ~299 days

Total

16

Last Release

1594d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3592619?v=4)[Kartik Visweswaran](/maintainers/kartik-v)[@kartik-v](https://github.com/kartik-v)

---

Top Contributors

[![kartik-v](https://avatars.githubusercontent.com/u/3592619?v=4)](https://github.com/kartik-v "kartik-v (130 commits)")[![exromany](https://avatars.githubusercontent.com/u/359612?v=4)](https://github.com/exromany "exromany (2 commits)")[![nbogol](https://avatars.githubusercontent.com/u/2125591?v=4)](https://github.com/nbogol "nbogol (2 commits)")[![fg](https://avatars.githubusercontent.com/u/2738851?v=4)](https://github.com/fg "fg (1 commits)")[![bijoys](https://avatars.githubusercontent.com/u/7283430?v=4)](https://github.com/bijoys "bijoys (1 commits)")[![khvalov](https://avatars.githubusercontent.com/u/2668527?v=4)](https://github.com/khvalov "khvalov (1 commits)")[![markux](https://avatars.githubusercontent.com/u/373611?v=4)](https://github.com/markux "markux (1 commits)")

---

Tags

builderyii2extensionwidgetform

### Embed Badge

![Health badge](/badges/kartik-v-yii2-builder/health.svg)

```
[![Health](https://phpackages.com/badges/kartik-v-yii2-builder/health.svg)](https://phpackages.com/packages/kartik-v-yii2-builder)
```

###  Alternatives

[kartik-v/yii2-widgets

Collection of useful widgets for Yii Framework 2.0 extending functionalities for Bootstrap

5593.9M116](/packages/kartik-v-yii2-widgets)[kartik-v/yii2-widget-select2

Enhanced Yii2 wrapper for the Select2 jQuery plugin (sub repo split from yii2-widgets).

3279.7M191](/packages/kartik-v-yii2-widget-select2)[kartik-v/yii2-detail-view

Enhanced Yii 2 Detail View widget with special Bootstrap styles, ability to edit data, and more.

701.1M41](/packages/kartik-v-yii2-detail-view)[kartik-v/yii2-widget-typeahead

Enhanced Yii2 wrapper for the Twitter Typeahead plugin (sub repo split from yii2-widgets).

454.8M9](/packages/kartik-v-yii2-widget-typeahead)[kartik-v/yii2-widget-colorinput

An enhanced Yii 2 widget encapsulating the HTML 5 color input (sub repo split from yii2-widgets)

324.8M10](/packages/kartik-v-yii2-widget-colorinput)[thiagotalma/yii2-jstree

Widget for Yii Framework 2.0 to use JsTree

3261.5k2](/packages/thiagotalma-yii2-jstree)

PHPackages © 2026

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