mirror of
https://github.com/silverstripe/silverstripe-tagfield
synced 2024-10-22 11:05:32 +02:00
Merge pull request #40 from 3Dgoo/feature/readme-fixes
Little fixes to read me example code.
This commit is contained in:
commit
4f86c021cf
17
README.md
17
README.md
@ -18,7 +18,7 @@
|
||||
|
||||
```php
|
||||
class BlogPost extends DataObject {
|
||||
static $many_many = array(
|
||||
private static $many_many = array(
|
||||
'BlogTags' => 'BlogTag'
|
||||
);
|
||||
}
|
||||
@ -26,11 +26,11 @@ class BlogPost extends DataObject {
|
||||
|
||||
```php
|
||||
class BlogTag extends DataObject {
|
||||
static $db = array(
|
||||
private static $db = array(
|
||||
'Title' => 'Varchar(200)',
|
||||
);
|
||||
|
||||
static $belongs_many_many = array(
|
||||
private static $belongs_many_many = array(
|
||||
'BlogPosts' => 'BlogPost'
|
||||
);
|
||||
}
|
||||
@ -41,17 +41,17 @@ $field = TagField::create(
|
||||
'BlogTags',
|
||||
'Blog Tags',
|
||||
BlogTag::get(),
|
||||
$post->BlogTags()
|
||||
$this->BlogTags()
|
||||
)
|
||||
->setShouldLazyLoad(true) // tags should be lazy loaded
|
||||
->setCanCreate(true); // new tag DataObjects can be created
|
||||
->setCanCreate(true); // new tag DataObjects can be created
|
||||
```
|
||||
|
||||
### String Tags
|
||||
|
||||
```php
|
||||
class BlogPost extends DataObject {
|
||||
static $db = array(
|
||||
private static $db = array(
|
||||
'Tags' => 'Text'
|
||||
);
|
||||
}
|
||||
@ -59,7 +59,10 @@ class BlogPost extends DataObject {
|
||||
|
||||
```php
|
||||
$field = StringTagField::create(
|
||||
'Tags', 'Tags', array('one', 'two'), explode(',', $this->Tags)
|
||||
'Tags',
|
||||
'Tags',
|
||||
array('one', 'two'),
|
||||
explode(',', $this->Tags)
|
||||
);
|
||||
|
||||
$field->setShouldLazyLoad(true); // tags should be lazy loaded
|
||||
|
Loading…
Reference in New Issue
Block a user