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
|
```php
|
||||||
class BlogPost extends DataObject {
|
class BlogPost extends DataObject {
|
||||||
static $many_many = array(
|
private static $many_many = array(
|
||||||
'BlogTags' => 'BlogTag'
|
'BlogTags' => 'BlogTag'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -26,11 +26,11 @@ class BlogPost extends DataObject {
|
||||||
|
|
||||||
```php
|
```php
|
||||||
class BlogTag extends DataObject {
|
class BlogTag extends DataObject {
|
||||||
static $db = array(
|
private static $db = array(
|
||||||
'Title' => 'Varchar(200)',
|
'Title' => 'Varchar(200)',
|
||||||
);
|
);
|
||||||
|
|
||||||
static $belongs_many_many = array(
|
private static $belongs_many_many = array(
|
||||||
'BlogPosts' => 'BlogPost'
|
'BlogPosts' => 'BlogPost'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -41,17 +41,17 @@ $field = TagField::create(
|
||||||
'BlogTags',
|
'BlogTags',
|
||||||
'Blog Tags',
|
'Blog Tags',
|
||||||
BlogTag::get(),
|
BlogTag::get(),
|
||||||
$post->BlogTags()
|
$this->BlogTags()
|
||||||
)
|
)
|
||||||
->setShouldLazyLoad(true) // tags should be lazy loaded
|
->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
|
### String Tags
|
||||||
|
|
||||||
```php
|
```php
|
||||||
class BlogPost extends DataObject {
|
class BlogPost extends DataObject {
|
||||||
static $db = array(
|
private static $db = array(
|
||||||
'Tags' => 'Text'
|
'Tags' => 'Text'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,10 @@ class BlogPost extends DataObject {
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$field = StringTagField::create(
|
$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
|
$field->setShouldLazyLoad(true); // tags should be lazy loaded
|
||||||
|
|
Loading…
Reference in New Issue