• Stars
    star
    100
  • Rank 328,770 (Top 7 %)
  • Language
    PHP
  • License
    Other
  • Created about 10 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Build forms (single or tabular) easily for Yii Framework 2.0.

Krajee Logo
yii2-builder
Donate Β  Β  Β  kartikv

Latest Stable Version Latest Unstable Version License Total Downloads Monthly Downloads Daily Downloads

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 for this extension's requirements and dependencies.

Latest Release

Refer the CHANGE LOG for details on changes to various releases.

Docs & Demo

You can see detailed docs & demos and the API code documentation on usage of the extension.

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.
  • 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) 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

\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

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 and the kartik\widgets\ActiveForm 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 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

You can see detailed documentation on usage of the extension.

Installation

The preferred way to install this extension is through composer.

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

Form

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

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

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' => '<i class="fas fa-book"></i> Manage Books',
            'type' => GridView::TYPE_PRIMARY,
            'after'=> 
                Html::a(
                    '<i class="fas fa-plus"></i> Add New', 
                    $createUrl, 
                    ['class'=>'btn btn-success']
                ) . '&nbsp;' . 
                Html::a(
                    '<i class="fas fa-times"></i> Delete', 
                    $deleteUrl, 
                    ['class'=>'btn btn-danger']
                ) . '&nbsp;' .
                Html::submitButton(
                    '<i class="fas fa-save"></i> Save', 
                    ['class'=>'btn btn-primary']
                )
        ]
    ]     
]); 
ActiveForm::end(); 

License

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

More Repositories

1

bootstrap-fileinput

An enhanced HTML 5 file input for Bootstrap 5.x/4.x./3.x with file preview, multiple selection, and more features.
JavaScript
5,330
star
2

bootstrap-star-rating

A simple yet powerful JQuery star rating plugin with fractional rating support.
JavaScript
1,049
star
3

yii2-widgets

Collection of useful widgets for Yii Framework 2.0
PHP
560
star
4

yii2-grid

Enhanced GridView with various utilities for Yii Framework 2.0
PHP
557
star
5

yii2-widget-select2

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

yii2-widget-fileinput

An enhanced FileInput widget for Bootstrap 4.x/3.x with file preview, multiple selection, and more features (sub repo split from yii2-widgets)
PHP
231
star
7

dependent-dropdown

JQuery plugin that enables to add and control multi level dependent dropdown lists.
JavaScript
182
star
8

yii2-export

A library to export server/db data in various formats (e.g. excel, html, pdf, csv etc.)
PHP
163
star
9

yii2-mpdf

A Yii2 wrapper component for the mPDF library which generates PDF files from UTF-8 encoded HTML.
CSS
161
star
10

yii2-tree-manager

An advanced tree management module using nested sets for Yii 2.
PHP
150
star
11

bootstrap-popover-x

Bootstrap popover extended with modal properties and more.
116
star
12

yii2-editable

An enhanced editable widget for Yii 2.0 that allows easy editing of displayed data with html inputs, widgets and more.
PHP
113
star
13

yii2-widget-datepicker

Enhanced Yii2 wrapper for the bootstrap datepicker plugin (sub repo split from yii2-widgets)
PHP
113
star
14

yii2-widget-datetimepicker

Enhanced Yii2 wrapper for the bootstrap datetimepicker plugin (sub repo split from yii2-widgets)
PHP
105
star
15

bootstrap-tabs-x

Bootstrap tabs supercharged with various alignment and styling options
100
star
16

bootstrap-checkbox-x

An extended checkbox plugin for bootstrap with three states and additional styles.
JavaScript
95
star
17

yii2-date-range

A Date Range Picker for Bootstrap useful for reports and filtering.
JavaScript
92
star
18

yii2-social

A Yii2 module for embedding social plugins and widgets.
PHP
92
star
19

yii2-markdown

Advanced Markdown editing and conversion utilities for Yii Framework 2.0
PHP
90
star
20

yii2-helpers

Collection of useful helper functions for Yii Framework 2.0
PHP
88
star
21

strength-meter

A dynamic strength meter for password input validation with various configurable options.
JavaScript
88
star
22

yii2-widget-depdrop

Widget that enables setting up dependent dropdowns with nested dependencies (sub repo split from yii2-widgets).
PHP
83
star
23

yii2-password

Useful password strength validation utilities for Yii Framework 2.0
PHP
74
star
24

yii2-dynagrid

Turbo charge the Yii 2 GridView with personalized columns, page size, and themes.
PHP
74
star
25

yii2-icons

Set of icon frameworks for easy use in Yii Framework 2.0
CSS
71
star
26

yii2-detail-view

Various enhancements to the Yii 2 Detail View with ability to edit data and manage styles using BS3.
PHP
71
star
27

yii2-krajee-base

Foundation classes and components used by Krajee Yii2 extensions
PHP
67
star
28

yii2-app-practical

Yii 2 Practical Project Template (based on advanced app)
PHP
66
star
29

yii2-widget-activeform

Enhanced Yii2 active-form and active-field with full bootstrap styling support (sub repo split from yii2-widgets).
PHP
63
star
30

yii2-datecontrol

Date control module allowing separation of date formats for View & Model for Yii Framework 2.0.
PHP
54
star
31

yii2-dialog

An extension that wraps bootstrap3-dialog for Yii 2.0 framework
PHP
49
star
32

yii2-widget-typeahead

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

php-date-formatter

A Javascript datetime formatting and manipulation library using PHP date-time formats.
JavaScript
44
star
34

yii2-widget-rating

A Yii2 widget for the simple yet powerful bootstrap-star-rating plugin with fractional rating support (sub repo split from yii2-widgets)
PHP
44
star
35

yii2-sortable

Create sortable lists and grids using HTML5 drag and drop API for Yii 2.0.
JavaScript
43
star
36

yii2-widget-timepicker

Enhanced Yii2 wrapper for the bootstrap timepicker plugin (sub repo split from yii2-widgets).
PHP
41
star
37

krajee-markdown-editor

A Boostrap styled markdown editor that offers configurable toolbar, live preview, export, fullscreen mode, and more features
JavaScript
41
star
38

mpdf

Fork of the mPDF latest DEV library (unofficial) with composer and packagist support.
PHP
40
star
39

yii2-widget-switchinput

A Yii2 wrapper widget for the Bootstrap Switch plugin to use checkboxes & radios as toggle switches (sub repo split from yii2-widgets)
PHP
38
star
40

yii2-widget-growl

A widget to generate growl based notifications using bootstrap-growl plugin (sub repo split from yii2-widgets)
PHP
38
star
41

yii2-widget-sidenav

An enhanced side navigation menu styled for bootstrap (sub repo split from yii2-widgets)
PHP
36
star
42

bootstrap-fileinput-samples

Example files for the bootstrap-fileinput plugin
35
star
43

yii2-app-practical-a

Yii 2 Practical-A ProjectTemplate (based on advanced app)
PHP
34
star
44

yii2-widget-colorinput

An enhanced Yii2 widget encapsulating the HTML 5 color input (sub repo split from yii2-widgets)
JavaScript
32
star
45

yii2-tabs-x

Extended bootstrap tabbed navigation widget for Yii 2.0 with various alignment and styling options.
PHP
30
star
46

yii2-app-practical-b

Yii 2 Practical Application Template (based on basic app)
PHP
30
star
47

yii2-widget-alert

An extended bootstrap alert and alert block widget for Yii2 (sub repo split from yii2-widgets)
PHP
28
star
48

yii2-nav-x

Extended bootstrap Nav widget with submenu option for Yii 2.
PHP
28
star
49

yii2-widget-spinner

A widget to render animated CSS3 loading spinners with VML fallback for IE (sub repo split from yii2-widgets)
JavaScript
28
star
50

yii2-slider

A slider input with orientations, range selections and more features based on bootstrap-slider.
PHP
28
star
51

yii2-ipinfo

An IP address information display widget for Yii 2 with country flag and geo position info
PHP
27
star
52

yii2-money

An advanced money mask input for Yii 2.0 styled for Bootstrap 3
JavaScript
26
star
53

yii2-checkbox-x

Extended checkbox widget for bootstrap with three states and additional styles for Yii 2.
PHP
25
star
54

yii2-field-range

Easily manage Yii 2 ActiveField ranges (from/to) with Bootstrap 3.x / 4.x addons markup and more.
PHP
24
star
55

yii2-popover-x

Extended bootstrap popover for Yii 2.0 with modal behavior and various styling options.
PHP
23
star
56

yii2-sortable-input

An input widget based on yii2-sortable extension allowing to store/save the sort order.
PHP
23
star
57

yii2-number

A number format mask control and input for Yii2 Framework
PHP
22
star
58

yii2-editors

Yii2 editor widgets Summernote and Codemirror.
PHP
21
star
59

yii2-validators

Enhanced Yii2 model validator components / utilities for Yii2 Framework
PHP
20
star
60

yii2-widget-rangeinput

An enhanced Yii 2 widget encapsulating the HTML 5 range input (sub repo split from yii2-widgets)
PHP
19
star
61

yii2-widget-touchspin

Yii2 wrapper for the bootstrap-touchspin spinner component (sub repo split from yii2-widgets)
JavaScript
18
star
62

yii2-widget-affix

A scrollspy and affixed enhanced navigation to highlight page sections (sub repo split from yii2-widgets)
PHP
15
star
63

yii2-dropdown-x

An extended bootstrap dropdown widget for Yii 2 with submenu drilldown.
PHP
15
star
64

yii2-label-inplace

A form enhancement widget for in-field label support.
JavaScript
11
star
65

yii2-bootstrap4-dropdown

Enhanced Bootstrap 4 dropdown widget for Yii2 framework with nested submenu support.
PHP
9
star
66

yii2-word-report

Make reports in Yii2 with Microsoft Word Templates
PHP
9
star
67

yii2-report

Create reports out of MS Word templates using PHP-Reports api.
PHP
8
star
68

yii2-context-menu

Yii 2 context menu extension with Bootstrap 3 styling.
PHP
7
star
69

yii2-filesystem

File system handling utilities and components
PHP
6
star
70

yii2-mail-manager

Mailer management module with queuing and administration
PHP
6
star
71

yii2-rest-api

Yii2 Rest API Template
PHP
5
star
72

yii2-mailer

A mail management module for Yii 2.0 with ability to manage mail queues, templates, and more.
4
star
73

yii2-mxgraph

Yii2 port of the MxGraph library
3
star
74

yii2-google-docs

2
star
75

yii2-query-filter

Advanced Yii2 query filters via an easy user interface
1
star
76

kartik-v

1
star
77

yii2-bootstrap5-dropdown

Enhanced Bootstrap 5 dropdown widget for Yii2 framework with nested submenu support
PHP
1
star