Merge branch '3'

This commit is contained in:
Daniel Hensby 2016-09-07 09:31:23 +01:00
commit 918fb94396
No known key found for this signature in database
GPG Key ID: 229831A941962E26
6 changed files with 38 additions and 11 deletions

View File

@ -1442,9 +1442,9 @@ class Versioned extends DataExtension implements TemplateGlobalProvider {
}
/**
* Get the latest published DataObject.
* Is the latest version of the object published?
*
* @return DataObject
* @return bool
*/
public function latestPublished() {
// Get the root data object class - this will have the version field

View File

@ -335,7 +335,7 @@ class HTTP {
* @param string $etag
*/
public static function register_etag($etag) {
if (0 !== strpos('"')) {
if (0 !== strpos($etag, '"')) {
$etag = sprintf('"%s"', $etag);
}
self::$etag = $etag;

View File

@ -43,6 +43,13 @@ We can represent multiple instances of them in `YAML` as follows:
**mysite/tests/fixtures.yml**
:::yml
Team:
hurricanes:
Name: The Hurricanes
Origin: Wellington
crusaders:
Name: The Crusaders
Origin: Canterbury
Player:
john:
Name: John
@ -53,13 +60,6 @@ We can represent multiple instances of them in `YAML` as follows:
jack:
Name: Jack
Team: =>Team.crusaders
Team:
hurricanes:
Name: The Hurricanes
Origin: Wellington
crusaders:
Name: The Crusaders
Origin: Canterbury
This `YAML` is broken up into three levels, signified by the indentation of each line. In the first level of
indentation, `Player` and `Team`, represent the class names of the objects we want to be created.
@ -88,6 +88,10 @@ Note that we use the name of the relationship (Team), and not the name of the
database field (TeamID).
</div>
<div class="hint" markdown='1'>
Also be aware the target of a relationship must be defined before it is referenced, for example the `hurricanes` team must appear in the fixture file before the line `Team: =>Team.hurricanes`.
</div>
This style of relationship declaration can be used for any type of relationship (i.e `has_one`, `has_many`, `many_many`).
We can also declare the relationships conversely. Another way we could write the previous example is:

View File

@ -18,6 +18,7 @@
* 2016-08-15 [ac26816](https://github.com/silverstripe/silverstripe-framework/commit/ac2681658ac33f6c060b7f5f881bd94eba92791b) Fix regression in url concatenation #4967 (Damian Mooyman)
* 2016-08-15 [ef85618](https://github.com/silverstripe/silverstripe-cms/commit/ef856185ab7a86f25fda718a88256c9e6e27a763) Fix regression in FormField casting (Damian Mooyman)
* 2016-08-02 [af3412a](https://github.com/silverstripe/silverstripe-framework/commit/af3412a4c2f3088f5647df0e366b9e1b6c41faa4) fix to grid field loading wrong current page id when using multiple tabs (John Milmine)
* 2016-08-02 [cd80d50](https://github.com/silverstripe/silverstripe-framework/commit/cd80d501f9eb12d9aca3e65f742041b142ee659f) Fix unset config options returning isset() = true (Damian Mooyman)
* 2016-08-01 [7d0b8e6](https://github.com/silverstripe/silverstripe-framework/commit/7d0b8e6520a246bd20204613233a0a6ad0f19437) Fix permission checking code not correctly handling escaped SQL identifiers (Damian Mooyman)
* 2016-07-28 [6c37532](https://github.com/silverstripe/silverstripe-framework/commit/6c37532a7ae4877fe1eaff45f41ff9902d5cccee) Gridfield delete action back link (#5848) (Jono Menz)

View File

@ -347,7 +347,14 @@ class DateField extends TextField {
$valid = true;
// Don't validate empty fields
if(empty($this->value)) return true;
if ($this->getConfig('dmyfields')) {
if (empty($this->value['day']) && empty($this->value['month']) && empty($this->value['year'])) {
return $valid;
}
}
elseif (empty($this->value)) {
return $valid;
}
// date format
if($this->getConfig('dmyfields')) {

View File

@ -115,6 +115,21 @@ class DateFieldTest extends SapphireTest {
$f = new DateField('Date', 'Date', 'wrong');
$this->assertFalse($f->validate(new RequiredFields()));
}
public function testEmptyValueValidation() {
$field = new DateField('Date');
$validator = new RequiredFields();
$this->assertTrue($field->validate($validator));
$field->setConfig('dmyfields', true);
$this->assertTrue($field->validate($validator));
$field->setValue(array(
'day' => '',
'month' => '',
'year' => '',
));
$this->assertTrue($field->validate($validator));
}
public function testValidateArray() {