Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
luischavez committed Aug 16, 2018
1 parent 9162b34 commit 11c034b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/en/model-form-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ $form->select('user_id')->options(function ($id) {
return [$user->id => $user->name];
}
})->ajax('/admin/api/users');

// using ajax and show selected item:

$form->select('user_id')->options(User::class)->ajax('/admin/api/users');

// or specifying the name and id

$form->select('user_id')->options(User::class, 'name', 'id')->ajax('/admin/api/users');
```

<sub>Notice:if you have modified the value of the `route.prefix` in the `config/admin.php` file, this api route should be modified to `config('admin.route.prefix').'/api/users'`.</sub>
Expand Down Expand Up @@ -171,6 +179,14 @@ public function city(Request $request)
## Multiple select
```php
$form->multipleSelect($column[, $label])->options([1 => 'foo', 2 => 'bar', 'val' => 'Option name']);

// using ajax and show selected items:

$form->multipleSelect($column[, $label])->options(Model::class)->ajax('ajax_url');

// or specifying the name and id

$form->multipleSelect($column[, $label])->options(Model::class, 'name', 'id')->ajax('ajax_url');
```

You can store value of multiple select in two ways, one is `many-to-many` relation.
Expand Down
16 changes: 16 additions & 0 deletions docs/zh/model-form-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ $form->select($column[, $label])->options([1 => 'foo', 2 => 'bar', 'val' => 'Opt
或者从api中获取选项列表:
```php
$form->select($column[, $label])->options('/api/users');

// 使用ajax并显示所选项目

$form->select($column[, $label])->options(Model::class)->ajax('/api/users');

// 或指定名称和ID

$form->select($column[, $label])->options(Model::class, 'name', 'id')->ajax('/api/users');
```
其中api接口的格式必须为下面格式:
```php
Expand Down Expand Up @@ -190,6 +198,14 @@ public function city(Request $request)

```php
$form->multipleSelect($column[, $label])->options([1 => 'foo', 2 => 'bar', 'val' => 'Option name']);

// 使用ajax并显示所选项目:

$form->multipleSelect($column[, $label])->options(Model::class)->ajax('ajax_url');

// 或指定名称和ID

$form->multipleSelect($column[, $label])->options(Model::class, 'name', 'id')->ajax('ajax_url');
```

多选框可以处理两种情况,第一种是`ManyToMany`的关系。
Expand Down

0 comments on commit 11c034b

Please sign in to comment.