mirror of
https://github.com/silverstripe/silverstripe-tagfield
synced 2024-10-22 11:05:32 +02:00
Merge pull request #106 from SilverStripers/master
Fixed performReadonlyTransformation
This commit is contained in:
commit
80d8cf6a04
@ -1,9 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\TagField\TagField;
|
||||
namespace SilverStripe\TagField;
|
||||
|
||||
use SilverStripe\Forms\ReadonlyField;
|
||||
use SilverStripe\TagField\TagField;
|
||||
|
||||
/**
|
||||
* A readonly extension of TagField useful for non-editable items within the CMS.
|
||||
@ -11,7 +10,7 @@ use SilverStripe\TagField\TagField;
|
||||
* @package forms
|
||||
* @subpackage fields
|
||||
*/
|
||||
class Readonly extends TagField
|
||||
class ReadonlyTagField extends TagField
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
@ -7,7 +7,6 @@ use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Forms\DropdownField;
|
||||
use SilverStripe\Forms\ReadonlyField;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
@ -67,7 +66,7 @@ class TagField extends DropdownField
|
||||
* @param null|DataList $source
|
||||
* @param null|DataList $value
|
||||
*/
|
||||
public function __construct($name, $title = '', $source = null, $value = null)
|
||||
public function __construct($name, $title = '', $source = array(), $value = null)
|
||||
{
|
||||
$this->setSourceList($source);
|
||||
parent::__construct($name, $title, $source, $value);
|
||||
@ -447,7 +446,7 @@ class TagField extends DropdownField
|
||||
*/
|
||||
public function performReadonlyTransformation()
|
||||
{
|
||||
$copy = $this->castedCopy(TagFieldReadonly::class);
|
||||
$copy = $this->castedCopy(ReadonlyTagField::class);
|
||||
$copy->setSourceList($this->getSourceList());
|
||||
return $copy;
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace SilverStripe\TagField\Tests;
|
||||
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\Form;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\TagField\ReadonlyTagField;
|
||||
use SilverStripe\TagField\TagField;
|
||||
use SilverStripe\TagField\Tests\Stub\TagFieldTestBlogPost;
|
||||
use SilverStripe\TagField\Tests\Stub\TagFieldTestBlogTag;
|
||||
@ -342,4 +342,14 @@ class TagFieldTest extends SapphireTest
|
||||
$record->Tags()->first()->ID
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test read only fields are returned
|
||||
*/
|
||||
public function testReadonlyTransformation()
|
||||
{
|
||||
$field = new TagField('Tags', '', TagFieldTestBlogTag::get());
|
||||
$readOnlyField = $field->performReadonlyTransformation();
|
||||
$this->assertEquals(ReadonlyTagField::class, get_class($readOnlyField));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user