Skip to content

Commit 8caf49a

Browse files
author
Eugene Tupikov
committed
continue writing documentation
1 parent fb8f746 commit 8caf49a

File tree

5 files changed

+50
-8
lines changed

5 files changed

+50
-8
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
Yii2 Multiple input widget.
2-
==================
1+
#Yii2 Multiple input widget.
32
Yii2 widget for handle multiple inputs for an attribute of model
43

5-
Installation
6-
------------
4+
##Installation
5+
76

87
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
98

@@ -21,8 +20,10 @@ or add
2120

2221
to the require section of your `composer.json` file.
2322

24-
Usage:
25-
------
26-
Look at examples for getting more details
23+
##Usage
24+
25+
26+
Widget supports several use cases. Use the following links for getting more information
2727

28-
Full documentation in progress.
28+
- [Single column example](docs/single_column.md)
29+
- [Several columns example](docs/several_columns.md)

docs/images/single-column.gif

228 KB
Loading

docs/several_columns.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#Several columns example
2+
3+
TBD

docs/single_column.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#Single column example
2+
3+
For example your application contains the model `User` that has the related model `UserEmail`
4+
You can add virtual attribute `emails` for collect emails from form and then you can save them to database.
5+
6+
In this case you can use `yii2-multiple-input` widget for supporting multiple inputs how to describe below.
7+
8+
First of all we have to declare virtual attribute in model
9+
10+
```
11+
class ExampleModel extends Model
12+
{
13+
/**
14+
* @var array virtual attribute for keeping emails
15+
*/
16+
public $emails;
17+
```

examples/models/ExampleModel.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,21 @@ class ExampleModel extends Model
1515
const TYPE_EMAIL = 'email';
1616
const TYPE_PHONE = 'phone';
1717

18+
/**
19+
* @var array virtual attribute for keeping emails
20+
*/
1821
public $emails;
1922

23+
/**
24+
* @var
25+
*/
2026
public $phones;
2127

28+
/**
29+
* @var
30+
*/
31+
public $schedule;
32+
2233

2334
public function rules()
2435
{
@@ -43,6 +54,11 @@ public function scenarios()
4354
];
4455
}
4556

57+
/**
58+
* Phone number validation
59+
*
60+
* @param $attribute
61+
*/
4662
public function validatePhones($attribute)
4763
{
4864
$items = $this->$attribute;
@@ -68,6 +84,11 @@ public function validatePhones($attribute)
6884
}
6985
}
7086

87+
/**
88+
* Email validation.
89+
*
90+
* @param $attribute
91+
*/
7192
public function validateEmails($attribute)
7293
{
7394
$items = $this->$attribute;

0 commit comments

Comments
 (0)