All Projects → bupy7 → yii2-dynamic-fields

bupy7 / yii2-dynamic-fields

Licence: BSD-3-Clause license
Widget for display dynamic fields, adding and removing their using Pjax.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to yii2-dynamic-fields

ar-dynattribute
Provide ActiveRecord dynamic attributes stored into the single field in serialized state
Stars: ✭ 43 (-17.31%)
Mutual labels:  yii2, dynamic
yii2-tinymce
Yii2 extension, tinymce wysiwyg editor
Stars: ✭ 16 (-69.23%)
Mutual labels:  yii2
yii2-behaviors
Collection of useful behaviors for Yii Framework 2.0
Stars: ✭ 25 (-51.92%)
Mutual labels:  yii2
yii2-basic-firestarter
This is a pimped up basic yii2 template ❤️. It's a firestarter 🔥
Stars: ✭ 35 (-32.69%)
Mutual labels:  yii2
ImmediateReflection
.NET library that aims to provide faster usage of C# reflection features. Especially the usage of constructor and members accessors (get/set). It also provides an ObjectWrapper object allowing to use Reflection in a faster way. And finally it offers the possibility to create strongly typed delegates.
Stars: ✭ 30 (-42.31%)
Mutual labels:  dynamic
yii2-cookiemonster
Yii extension to manage cookie warning
Stars: ✭ 16 (-69.23%)
Mutual labels:  yii2
yii2-docker-app-advanced
Yii 2 Advanced Project Template under docker and docker-compose
Stars: ✭ 25 (-51.92%)
Mutual labels:  yii2
api
CashWarden API
Stars: ✭ 34 (-34.62%)
Mutual labels:  yii2
yii2-ledap
yii2 for ledap
Stars: ✭ 20 (-61.54%)
Mutual labels:  yii2
python-makefun
Dynamically create python functions with a proper signature.
Stars: ✭ 62 (+19.23%)
Mutual labels:  dynamic
yii2-highcharts-widget
HighCharts Js Widget for Yii2
Stars: ✭ 40 (-23.08%)
Mutual labels:  yii2
menapro
CMS of 2017
Stars: ✭ 20 (-61.54%)
Mutual labels:  yii2
python-autoclass
A python 3 library providing functions and decorators to automatically generate class code, such as constructor body or properties getters/setters along with optional support of validation contracts on the generated setters. Its objective is to reduce the amount of copy/paste code in your classes - and hence to help reducing human mistakes :).
Stars: ✭ 30 (-42.31%)
Mutual labels:  fields
Meh
Python configuration files in Python. ¯\_(ツ)_/¯
Stars: ✭ 20 (-61.54%)
Mutual labels:  dynamic
filedb
ActiveRecord for static data definitions based on files
Stars: ✭ 72 (+38.46%)
Mutual labels:  yii2
anchor
Create Dynamic CLI's as your GitOps Marketplace
Stars: ✭ 38 (-26.92%)
Mutual labels:  dynamic
readme-typing-svg
⚡ Dynamically generated, customizable SVG that gives the appearance of typing and deleting text. Typing SVGs can be used as a bio on your Github profile readme or repository.
Stars: ✭ 938 (+1703.85%)
Mutual labels:  dynamic
JqueryDataTablesServerSideDemo
Jquery DataTables with Asp.Net Core server side multi column sorting and searching Demo Project.
Stars: ✭ 43 (-17.31%)
Mutual labels:  dynamic
yii2-merit
Reputation engine for Yii2 用于实现积分,等级功能的设计
Stars: ✭ 16 (-69.23%)
Mutual labels:  yii2
awesome-csv
Awesome Comma-Separated Values (CSV) - What's Next? - Frequently Asked Questions (F.A.Q.s) - Libraries & Tools
Stars: ✭ 46 (-11.54%)
Mutual labels:  fields

yii2-dynamic-fields

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

Screenshot

Installation

The preferred way to install this extension is through composer.

Either run

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

or add

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

to the require section of your composer.json file.

Usage

Add following code to your view:

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:

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].