Skip to content

Commit db1c7af

Browse files
committed
Added readme
1 parent a377aa6 commit db1c7af

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

readme.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# SilverStripe Segment Field
2+
3+
[![Build Status](http://img.shields.io/travis/assertchris/silverstripe-segment-field.svg?style=flat-square)](https://travis-ci.org/assertchris/silverstripe-segment-field)
4+
[![Code Quality](http://img.shields.io/scrutinizer/g/assertchris/silverstripe-segment-field.svg?style=flat-square)](https://scrutinizer-ci.com/g/assertchris/silverstripe-segment-field)
5+
[![Code Coverage](http://img.shields.io/scrutinizer/coverage/g/assertchris/silverstripe-segment-field.svg?style=flat-square)](https://scrutinizer-ci.com/g/assertchris/silverstripe-segment-field)
6+
[![Version](http://img.shields.io/packagist/v/silverstripe/segment-field.svg?style=flat-square)](https://packagist.org/packages/silverstripe/segment-field)
7+
[![License](http://img.shields.io/packagist/l/silverstripe/segment-field.svg?style=flat-square)](license.md)
8+
9+
A reusable approach to segment-generating fields.
10+
11+
## Usage
12+
13+
```php
14+
SegmentField::create('PageName')->setModifiers(array(
15+
SlugSegmentFieldModifier::create()->setDefault('page'),
16+
array('-', ''),
17+
IDSegmentFieldModifier::create(),
18+
))->setPreview($this->PageDisplayName)
19+
```
20+
21+
1. Starting with a value of "My New Page!"
22+
2. The value is passed through `SlugSegmentFieldModifier`.
23+
3. Preview value becomes "My-New-Page", Input value becomes "My-New-Page".
24+
4. The value is passed through `array('-', '')`.
25+
5. Preview value becomes "My-New-Page-", Input value becomes "My-New-Page".
26+
6. The value is passed through `IDSegmentFieldModifier`.
27+
7. Preview value becomes "My-New-Page-1" (the ID of the DataObject), Input value becomes "My-New-Page".
28+
29+
You can pass any similarly structured array or implementation of `SilverStripe\Forms\SegmentFieldModifier` in the modifiers list.
30+
31+
## Versioning
32+
33+
This library follows [Semver](http://semver.org). According to Semver, you will be able to upgrade to any minor or patch version of this library without any breaking changes to the public API. Semver also requires that we clearly define the public API for this library.
34+
35+
All methods, with `public` visibility, are part of the public API. All other methods are not part of the public API. Where possible, we'll try to keep `protected` methods backwards-compatible in minor/patch versions, but if you're overriding methods then please test your work before upgrading.
36+
37+
## Thanks
38+
39+
I'd like to thank [SilverStripe](http://www.silverstripe.com) for letting me work on fun projects like this. Feel free to talk to me about using the [framework and CMS](http://www.silverstripe.org) or [working at SilverStripe](http://www.silverstripe.com/who-we-are/#careers).

0 commit comments

Comments
 (0)