2017 © Pedro Peláez
 

yii2-extension yii2-dynamic-fields

Widget for display dynamic fields, adding and removing their use Pjax.

image

bupy7/yii2-dynamic-fields

Widget for display dynamic fields, adding and removing their use Pjax.

  • Monday, March 26, 2018
  • by bupy7
  • Repository
  • 11 Watchers
  • 53 Stars
  • 2,250 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 16 Forks
  • 2 Open issues
  • 4 Versions
  • 5 % Grown

The README.md

yii2-dynamic-fields

Widget for display dynamic fields, adding and removing their use Pjax., (*1)

Screenshot, (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require --prefer-dist bupy7/yii2-dynamic-fields "*"

or add, (*5)

"bupy7/yii2-dynamic-fields": "*"

to the require section of your composer.json file., (*6)

Usage

Add following code to your view:, (*7)

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use bupy7\dynafields\DynaFields;

$form = ActiveForm::begin(['action' => ['index']]);

echo DynaFields::widget([
    'urlAdd' => ['your-action-add'],
    'urlRemove' => ['your-action-remove'],
    'inputMethod' => 'textInput',
    'inputMethodArgs' => [['maxlength' => true]],
    'form' => $form,
    'models' => $models,
    'attribute' => 'attribute',
]);

echo Html::submitButton('Save', ['class' => 'btn btn-success']);

ActiveForm::end();

Added following code to your controller:, (*8)

use Yii;
use yii\base\Model;

/**
 * Render form.
 */
public function actionIndex() 
{
    $models = ModelName::find()->all();
    if (Model::loadMultiple($models, Yii::$app->request->post()) && Model::validateMultiple($models)) {
        for ($i = 0; $i != count($models); $i++) {
            $models[$i]->save(false);
        }
        return $this->redirect(['index']);
    }
    return $this->render('index', ['models' => $models]); 
}

/**
 * Create new model.
 */
public function actionYourActionAdd()
{ 
    $model = new ModelName;
    $model->save(false);
    return $this->actionIndex();
}

/**
 * Delete model.
 * @param int $id
 */
public function actionYourActionRemove($id)
{
    ModelName::findOne($id)->delete();
    return $this->actionIndex();
}

License

yii2-dynamic-fields is released under the BSD 3-Clause License., (*9)

The Versions

26/03 2018

dev-master

9999999-dev https://github.com/bupy7/yii2-dynamic-fields

Widget for display dynamic fields, adding and removing their use Pjax.

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 widget multiple dynamic fields pjax

26/03 2018

1.0.2

1.0.2.0 https://github.com/bupy7/yii2-dynamic-fields

Widget for display dynamic fields, adding and removing their use Pjax.

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 widget multiple dynamic fields pjax

24/08 2015

1.0.1

1.0.1.0 https://github.com/bupy7/yii2-dynamic-fields

Widget for display dynamic fields, adding and removing their use Pjax.

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 widget multiple dynamic fields pjax

27/03 2015

v1.0.0

1.0.0.0 https://github.com/bupy7/yii2-dynamic-fields

Widget for display dynamic fields, adding and removing their use Pjax.

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 widget multiple dynamic fields pjax