Skip to content

Commit 250d171

Browse files
authored
Merge pull request #9 from codem/docs-update
(docs) update
2 parents 4817df7 + 15eff01 commit 250d171

File tree

4 files changed

+39
-19
lines changed

4 files changed

+39
-19
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ See [License](./LICENSE.md)
5959

6060
* [Documentation](./docs/en/001_index.md)
6161

62-
6362
## Configuration
6463

6564
Hopefully none !

docs/en/001_index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
[Inputs](./002_inputs.md)
66

77
## Media types
8+
9+
TBC

docs/en/002_inputs.md

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Input examples
1+
# Input examples
22

33
> Note: the inputs are rendered by the browser native controls
44
@@ -9,22 +9,21 @@
99
+ This field only supports 6chr hex values as per the W3C spec.
1010

1111
```php
12+
<?php
1213
// or ColorField if you are en-us
1314
$fields->addFieldToTab(
14-
'Root.Main'
15+
'Root.Main',
1516
ColourField::create('TertiaryColour')
1617
);
1718
```
19+
1820
### Example HTML
1921

2022
```html
2123
<input type="color" id="field" name="field" value="#00bedf">
2224
```
23-
If your markdown interpreter renders this, you will see an HTML colour picker field:
24-
25-
<input type="color" id="field" name="field" value="#00bedf">
2625

27-
<hr>
26+
Chrome example:
2827

2928
![Colour Field output in Chrome](../img/colourfield.png)
3029

@@ -43,37 +42,55 @@ With a `<datalist>`, although note that browsers will allow other colours to be
4342
</datalist>
4443
```
4544

46-
Again, an HTML example:
45+
No need for fancy JS pickers when the browser can do it just as easily. Non supporting browsers will fallback to a text input field.
4746

48-
<input type="color" id="field" name="field" value="#00bedf" list="colours">
49-
<datalist id="colours">
50-
<option>#ff0000</option>
51-
<option>#0000ff</option>
52-
<option>#00ff00</option>
53-
<option>#ffff00</option>
54-
<option>#00ffff</option>
55-
</datalist>
47+
### Nullable colour field
5648

57-
<hr>
49+
Colour inputs do not allow a null/empty value to be selected. To allow empty values, use the core `NullableField` together with a `ColourField`, or implement a separate checkbox field:
5850

59-
No need for fancy JS pickers when the browser can do it just as easily. Non supporting browsers will fallback to a text input field.
51+
```php
52+
<?php
53+
$nullableColourField = \SilverStripe\Forms\NullableField::create(
54+
\Codem\Utilities\HTML5\ColourField::create(
55+
"CustomColour", "Custom colour"
56+
),
57+
"None"
58+
);
59+
```
60+
61+
You will need to apply layout/styling and data handling in your own project.
6062

6163
## URL Field
6264

6365
A good starting point is the `URLFieldTest` class:
6466

6567
```php
68+
<?php
6669
$url = 'ftp://www.example.com/path?foo=bar';
6770
$field = UrlField::create('TestURL', 'Test URL', $url);
6871
$pattern = "^ftp://.+\.com";
6972
$phpPattern = "|^ftp://.+\.com|";
7073
$field->setPattern($pattern, $phpPattern);
7174
```
7275

73-
## Methods available
76+
### Methods available
7477

7578
+ `setRequiredParts` - provide an array of URL parts the URL must have for validation to pass, the values being the keys from `parse_url()`
7679
+ `setPattern` - set complex and mystifying URL regular expression patterns in both JS and PHP
7780
+ `setSchemes` - set an array of schemes that the URL must start with (eg. `['blob', 'dict', 'dns']`)
7881
+ `restrictToHttp` - shorthand method, the URL must start with http:// OR https://
7982
+ `restrictToHttps` - shorthand method, the URL must start with https://
83+
84+
85+
## Traits
86+
87+
The fields use relevant traits based on their allowed attributes:
88+
89+
+ Datalist: for inputs that allow a HTMLDataListElement to be attached
90+
+ MinMax: for inputs that have a min or max
91+
+ Multiple: for inputs that allow multiple selections
92+
+ Pattern: for inputs that support the pattern attribute
93+
+ Step: for inputs that support the step attribute
94+
+ Core: a set of methods for core attributes for all inputs
95+
96+
See the RangeField for an example of usage.

docs/en/003_media.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Media related elements
22

3+
TBC
4+
35
## <video>
46

57

0 commit comments

Comments
 (0)