tigrov / yii2-array-field
ArrayField - Yii2 extension to edit array field in forms generated by ActiveForm.
Installs: 25
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: ~2.0.0
- yiisoft/yii2-bootstrap: ~2.0
This package is auto-updated.
Last update: 2024-12-05 01:18:52 UTC
README
The extension build a form field for array attribute of a model.
If you have array attributes in a model you can edit them using the extension.
It requires to use Bootstrap
library.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist tigrov/yii2-array-field
or add
"tigrov/yii2-array-field": "~1.0"
to the require section of your composer.json
file.
Usage
Specify class ArrayField
for a form field.
<?php $form = ActiveForm::begin(); ?>
...
<?= $form->field($model, 'phones', ['class' => ArrayField::class]) ?>
...
<?php $form::end(); ?>
$model->phones
must be an array.
Also it is possible to show it as input group.
<?php $form = ActiveForm::begin(); ?>
...
<?= $form->field($model, 'phones', ['class' => ArrayField::class, 'isInputGroup' => true]) ?>
...
<?php $form::end(); ?>
The result with "input group".