mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 14:05:56 +02:00
Merge pull request #140 from creative-commoners/pulls/2.0/rename-json-field
FIX Rename JsonField to DMSJsonField to add a pseudo-namespace
This commit is contained in:
commit
11819a1e16
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class JsonField combines form inputs into a key-value pair
|
* Combines form inputs into a key-value pair
|
||||||
*/
|
*/
|
||||||
class JsonField extends CompositeField
|
class DMSJsonField extends CompositeField
|
||||||
{
|
{
|
||||||
public function __construct($name, $children = null)
|
public function __construct($name, $children = null)
|
||||||
{
|
{
|
||||||
@ -90,7 +90,7 @@ class JsonField extends CompositeField
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets
|
* Sets the value
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
@ -212,7 +212,7 @@ class DMSDocumentSet extends DataObject
|
|||||||
$field->setMultiple(true)->setSource($map);
|
$field->setMultiple(true)->setSource($map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$keyValPairs = JsonField::create('KeyValuePairs', $dmsDocFields->toArray());
|
$keyValPairs = DMSJsonField::create('KeyValuePairs', $dmsDocFields->toArray());
|
||||||
|
|
||||||
// Now lastly add the sort fields
|
// Now lastly add the sort fields
|
||||||
$sortedBy = FieldGroup::create('SortedBy', array(
|
$sortedBy = FieldGroup::create('SortedBy', array(
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class JsonFieldTest extends SapphireTest
|
class DMSJsonFieldTest extends SapphireTest
|
||||||
{
|
{
|
||||||
public function testJsonFieldConstructorMultiWays()
|
public function testJsonFieldConstructorMultiWays()
|
||||||
{
|
{
|
||||||
$jsonField = new JsonField('MyJsonField', new FieldList(
|
$jsonField = new DMSJsonField('MyJsonField', new FieldList(
|
||||||
new TextField('FirstName', 'Given name'),
|
new TextField('FirstName', 'Given name'),
|
||||||
new TextField('Surname', 'Last name')
|
new TextField('Surname', 'Last name')
|
||||||
));
|
));
|
||||||
$this->assertEquals($jsonField->FieldList()->count(), 2);
|
$this->assertEquals($jsonField->FieldList()->count(), 2);
|
||||||
$this->assertNotNull($jsonField->FieldList()->dataFieldByName('MyJsonField[FirstName]'));
|
$this->assertNotNull($jsonField->FieldList()->dataFieldByName('MyJsonField[FirstName]'));
|
||||||
|
|
||||||
$jsonField = new JsonField('MyJsonField', array(new TextField('FirstName', 'Given name'),
|
$jsonField = new DMSJsonField('MyJsonField', array(new TextField('FirstName', 'Given name'),
|
||||||
new TextField('Surname', 'Last name')));
|
new TextField('Surname', 'Last name')));
|
||||||
$this->assertEquals($jsonField->FieldList()->count(), 2);
|
$this->assertEquals($jsonField->FieldList()->count(), 2);
|
||||||
$this->assertNotNull($jsonField->FieldList()->dataFieldByName('MyJsonField[FirstName]'));
|
$this->assertNotNull($jsonField->FieldList()->dataFieldByName('MyJsonField[FirstName]'));
|
||||||
|
|
||||||
$jsonField = new JsonField(
|
$jsonField = new DMSJsonField(
|
||||||
'MyJsonField',
|
'MyJsonField',
|
||||||
new TextField('FirstName', 'Given name'),
|
new TextField('FirstName', 'Given name'),
|
||||||
new TextField('Surname', 'Last name')
|
new TextField('Surname', 'Last name')
|
||||||
@ -27,7 +27,7 @@ class JsonFieldTest extends SapphireTest
|
|||||||
|
|
||||||
public function testJsonFieldDataValueCouldDealWithArray()
|
public function testJsonFieldDataValueCouldDealWithArray()
|
||||||
{
|
{
|
||||||
$jsonField = new JsonField('MyJsonField', new FieldList(
|
$jsonField = new DMSJsonField('MyJsonField', new FieldList(
|
||||||
new TextField('FirstName', 'Given name'),
|
new TextField('FirstName', 'Given name'),
|
||||||
new TextField('Surname', 'Last name')
|
new TextField('Surname', 'Last name')
|
||||||
));
|
));
|
Loading…
Reference in New Issue
Block a user