Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
update demo code
Browse files Browse the repository at this point in the history
  • Loading branch information
蓝小灰 committed Nov 9, 2017
1 parent 435a809 commit 5674cc6
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 17 deletions.
33 changes: 25 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,40 @@ $editable = new \Editable\Editable(
'id' => 12,
'name' => '张君宝',
'home' => '武当山',
'prefer' => 'php,html',
'gender' => 1,
'job' => 2,
'about' => 'Throne of the seven kingdoms,<br/> <i>Father of the dragon</i>, <b>stormborn</b>, <u>unburn</u>.',
'created_at' => date('Y-m-d H:i:s'),
],
'id',
['id', 'created_at'],
[],
'test.php?action=save'
);

$editable->typeahead('home', null, [
['value' => '武当山', 'tokens' => '武当山'],
['value' => '华山', 'tokens' => '华山'],
['value' => '峨眉山', 'tokens' => '峨眉山']
'武当山',
'华山',
'峨眉山',
'井冈山',
], 0);

$editable->checklist('job', null, [
['value' => 1, 'text' => '一代弱鸡'],
['value' => 2, 'text' => '一代宗师'],
['value' => 3, 'text' => '一代刺客']
], 0);
$editable->select('job', null, [
['value' => 1, 'text' => '一代弱鸡'],
['value' => 2, 'text' => '一代宗师'],
['value' => 3, 'text' => '一代刺客']

$editable->select('gender', null, [
['value' => 0, 'text' => '未知'],
['value' => 1, 'text' => '男'],
['value' => 2, 'text' => '女'],
], 0);

$editable->tag('prefer', null, ['css', 'js', 'google']);

$editable->wysiwyg('about');
$editable->datetime('created_at');
echo $editable->render()->getBody();
```

Expand Down
36 changes: 27 additions & 9 deletions README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,49 @@ composer require diana/php-x-editable -vvv

## 使用


```php
<?php
$editable = new \Editable\Editable(
[
'id' => 12,
'name' => '张君宝',
'home' => '武当山',
'prefer' => 'php,html',
'gender' => 1,
'job' => 2,
'about' => 'Throne of the seven kingdoms,<br/> <i>Father of the dragon</i>, <b>stormborn</b>, <u>unburn</u>.',
'created_at' => date('Y-m-d H:i:s'),
],
'id',
['id', 'created_at'],
[],
'test.php?action=save'
);

$editable->typeahead('home', null, [
['value' => '武当山', 'tokens' => '武当山'],
['value' => '华山', 'tokens' => '华山'],
['value' => '峨眉山', 'tokens' => '峨眉山']
'武当山',
'华山',
'峨眉山',
'井冈山',
], 0);
$editable->select('job', null, [
['value' => 1, 'text' => '一代弱鸡'],
['value' => 2, 'text' => '一代宗师'],
['value' => 3, 'text' => '一代刺客']

$editable->checklist('job', null, [
['value' => 1, 'text' => '一代弱鸡'],
['value' => 2, 'text' => '一代宗师'],
['value' => 3, 'text' => '一代刺客']
], 0);
echo $editable->render()->getBody(); // PSR-7,所以要用getBody来获取HTML

$editable->select('gender', null, [
['value' => 0, 'text' => '未知'],
['value' => 1, 'text' => '男'],
['value' => 2, 'text' => '女'],
], 0);

$editable->tag('prefer', null, ['css', 'js', 'google']);

$editable->wysiwyg('about');
$editable->datetime('created_at');
echo $editable->render()->getBody();
```

完整的DEMO例子请见 https://github.com/xiaohuilam/php-x-editable/blob/master/test/Editable.php
Expand Down

0 comments on commit 5674cc6

Please sign in to comment.