DynamicForm
Цей контент ще не доступний вашою мовою.
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
Section titled “Quick start”Installation
Section titled “Installation”composer require --prefer-dist yii2-extensions/dynamicform:^2.0Basic usage
Section titled “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><?phpDynamicFormWidget::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
Section titled “Documentation”AI assistance
Section titled “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:DynamicFormWidgetrows, nesting, client validation, events and enhanced controls, and server-side rebuilding of posted rows withModel::createMultiple(). - 🧭
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.
Special thanks
Section titled “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.
Our social networks
Section titled “Our social networks”Follow on X Follow on Facebook Join our Subreddit Join on Telegram
License
Section titled “License”Package
Section titled “Package”- Source code and issues: yii2-extensions/dynamicform. Star the repository if the package is useful to you.
- Composer package: yii2-extensions/dynamicform.
- Changelog: CHANGELOG.md.