Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Mar 16, 2021. It is now read-only.

Commit f0b0f6a

Browse files
committed
rewrite readme, fix bugs, release
1 parent 495428a commit f0b0f6a

File tree

7 files changed

+111
-15
lines changed

7 files changed

+111
-15
lines changed

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

‎DynaFields.php‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
use yii\widgets\Pjax;
1010

1111
/**
12-
* Widget for display dynamic fields.
12+
* Widget for display dynamic fields, adding and removing their use Pjax.
13+
*
14+
* Home page: https://github.com/bupy7/yii2-dynamic-fields
15+
*
16+
* @author Vasilij Belosludcev http://mihaly4.ru
1317
*/
1418
class DynaFields extends Widget
1519
{

‎LICENSE.md‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2015, Belosludcev Vasilij
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
* Neither the name of Belosludcev Vasilij or BuPy7 nor the names of its
15+
contributors may be used to endorse or promote products derived from
16+
this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

‎README.md‎

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
yii2-dynamic-fields
22
==================
3-
Widget for display dynamic fields.
3+
Widget for display dynamic fields, adding and removing their use Pjax.
4+
5+
![Screenshot](screenshot.png)
46

57
Installation
68
------------
@@ -10,7 +12,7 @@ The preferred way to install this extension is through [composer](http://getcomp
1012
Either run
1113

1214
```
13-
php composer.phar require --prefer-dist bupy7/yii2-dynamic-fields "*"
15+
php composer.phar require bupy7/yii2-dynamic-fields "*"
1416
```
1517

1618
or add
@@ -24,3 +26,72 @@ to the require section of your `composer.json` file.
2426

2527
Usage
2628
-----
29+
30+
Add following code to your view:
31+
32+
```php
33+
use yii\helpers\Html;
34+
use yii\widgets\ActiveForm;
35+
use bupy7\dynafields\DynaFields;
36+
37+
$form = ActiveForm::begin(['action' => ['index']]);
38+
39+
echo DynaFields::widget([
40+
'urlAdd' => ['your-action-add'],
41+
'urlRemove' => ['your-action-remove'],
42+
'inputMethod' => 'textInput',
43+
'inputMethodArgs' => [['maxlength' => true]],
44+
'form' => $form,
45+
'models' => $models,
46+
'attribute' => 'attribute',
47+
]);
48+
49+
echo Html::submitButton('Save', ['class' => 'btn btn-success']);
50+
51+
ActiveForm::end();
52+
```
53+
54+
Added following code to your controller:
55+
56+
```php
57+
use yii\base\Model;
58+
59+
/**
60+
* Render form.
61+
*/
62+
public function actionIndex()
63+
{
64+
$models = ModelName::find()->all();
65+
if (Model::loadMultiple($models, Yii::$app->request->post()) && Model::validateMultiple($models)) {
66+
for ($i = 0; $i != count($models); $i++) {
67+
$models[$i]->save(false);
68+
}
69+
return $this->redirect(['index']);
70+
}
71+
return $this->render('index', ['models' => $models]);
72+
}
73+
74+
/**
75+
* Create new model.
76+
*/
77+
public function actionYourActionAdd()
78+
{
79+
$model = new ModelName;
80+
$model->save(false);
81+
return $this->actionIndex();
82+
}
83+
84+
/**
85+
* Delete model.
86+
* @param int $id
87+
*/
88+
public function actionYourActionRemove($id)
89+
{
90+
ModelName::findOne($id)->delete();
91+
return $this->actionIndex();
92+
}
93+
```
94+
95+
##License
96+
97+
yii2-dynamic-fields is released under the BSD 3-Clause License.

‎composer.json‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
{
22
"name": "bupy7/yii2-dynamic-fields",
3-
"description": "Widget for display dynamic fields.",
3+
"description": "Widget for display dynamic fields, adding and removing their use Pjax.",
44
"homepage": "https://github.com/bupy7/yii2-dynamic-fields",
55
"type": "yii2-extension",
6-
"keywords": ["yii2","extension","widget","dynamicfields"],
6+
"keywords": ["yii2","extension","widget","dynamic", "fields", "pjax", "multiple"],
77
"license": "BSD-3-Clause",
88
"authors": [
99
{
1010
"name": "Belosludcev Vasilij",
11-
"email": "bupy765@gmail.com"
11+
"email": "bupy765@gmail.com",
12+
"homepage": "http://mihaly4.ru"
1213
}
1314
],
1415
"require": {
15-
"yiisoft/yii2": "*"
16+
"yiisoft/yii2-bootstrap": "@dev"
1617
},
1718
"autoload": {
1819
"psr-4": {

‎screenshot.png‎

12.6 KB
Loading[フレーム]

‎views/_text.php‎

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /