yii2-extensions / dynamicform
Yii2 widget for cloning nested form elements while maintaining accessibility and client validation.
Package info
github.com/yii2-extensions/dynamicform
Language:JavaScript
Type:yii2-extension
pkg:composer/yii2-extensions/dynamicform
Requires
- php: >=8.1
- ext-dom: *
- symfony/css-selector: ^6.4||^7.0
- symfony/dom-crawler: ^6.4||^7.0
- yiisoft/yii2: ^2.0.55 || ^22.0
Requires (Dev)
- bower-asset/inputmask: 5.0.10
- infection/infection: ^0.27 || ^0.35
- kartik-v/dependent-dropdown: 1.4.9
- kartik-v/yii2-krajee-base: 3.0.5
- kartik-v/yii2-money: 1.2.3
- kartik-v/yii2-number: 1.0.5
- kartik-v/yii2-widget-datepicker: 1.4.8
- kartik-v/yii2-widget-depdrop: 1.0.6
- kartik-v/yii2-widget-fileinput: 1.1.1
- kartik-v/yii2-widget-select2: 2.2.5
- kartik-v/yii2-widget-timepicker: 1.0.5
- kartik-v/yii2-widget-touchspin: 1.2.4
- maglnet/composer-require-checker: ^4.7
- php-forge/coding-standard: ^0.3
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-strict-rules: ^2.0.3
- phpunit/phpunit: ^10.5
- select2/select2: 4.0.13
- yii2-extensions/phpstan: ^0.4 || ^0.5
- yiisoft/yii2-bootstrap5: ^2.0.50
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-12 20:15:52 UTC
README
Dynamic form
Clone nested form rows in Yii2 ActiveForm
Tabular inputs, client validation, nested widgets and jQuery events
Add and remove rows of form fields in the browser while the tabular input names, ids and client validation stay
coherent. The widget wraps the rows rendered by ActiveForm, and the Model helper rebuilds the posted rows on the
server.
Quick start
Installation
composer require --prefer-dist yii2-extensions/dynamicform:^2.0
Basic usage
Wrap the rows of a tabular form with DynamicFormWidget::begin() and end():
use yii\helpers\Html; use yii\widgets\ActiveForm; use Yii2\Extensions\DynamicForm\DynamicFormWidget; $form = ActiveForm::begin(['id' => 'dynamic-form']); DynamicFormWidget::begin( [ 'widgetContainer' => 'dynamicform_wrapper', 'widgetBody' => '.container-items', 'widgetItem' => '.item', 'limit' => 4, 'min' => 1, 'insertButton' => '.add-item', 'deleteButton' => '.remove-item', 'model' => $modelsAddress[0], 'formId' => 'dynamic-form', 'formFields' => ['full_name', 'city'], ], ); ?> <div class="container-items"> <?php foreach ($modelsAddress as $i => $modelAddress): ?> <div class="item"> <?= $form->field($modelAddress, "[{$i}]full_name")->textInput() ?> <?= $form->field($modelAddress, "[{$i}]city")->textInput() ?> <button type="button" class="add-item">+</button> <button type="button" class="remove-item">-</button> </div> <?php endforeach; ?> </div> <?php DynamicFormWidget::end(); echo Html::submitButton('Save'); ActiveForm::end();
On the server, Model::createMultiple() builds one Address model per posted row; the
usage examples show the complete create and update actions.
Documentation
AI assistance
AI agents: read the documentation index and fetch the Markdown version
of a page by appending index.md to its URL. The
AI agents guide covers skill installation, client setup and
verification.
- 🤖
yii2-dynamicformskill: Dynamic form rows. - 🧭
yii2-frameworkskill: Yii 22.0 application conventions.
The hosted documentation covers Yii 22.0. If it does not match the installed revision or is unavailable, use the repository guides, the skill source, the source PHPDoc and the changelog.
Package information
Code quality
Special thanks
This extension was created by Wanderson Bragança and hosted at wbraganca/yii2-dynamicform. We thank him for his work; for continuity and maintenance we have moved a copy here and preserve his identity throughout the code he wrote.