mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
Merge pull request #683 from creative-commoners/pulls/5.0/update-icon-paths
FIX Update getIcon resource resolution methods
This commit is contained in:
commit
bcadbad092
@ -599,8 +599,17 @@ class EditableFormField extends DataObject
|
|||||||
*/
|
*/
|
||||||
public function getIcon()
|
public function getIcon()
|
||||||
{
|
{
|
||||||
return ModuleLoader::getModule('silverstripe/userforms')
|
$classNamespaces = explode("\\", static::class);
|
||||||
->getRelativeResourcePath('images/' . strtolower($this->class) . '.png');
|
$shortClass = end($classNamespaces);
|
||||||
|
|
||||||
|
$resource = ModuleLoader::getModule('silverstripe/userforms')
|
||||||
|
->getResource('images/' . strtolower($shortClass) . '.png');
|
||||||
|
|
||||||
|
if (!$resource->exists()) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $resource->getURL();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,8 +55,13 @@ class EditableCountryDropdownField extends EditableFormField
|
|||||||
|
|
||||||
public function getIcon()
|
public function getIcon()
|
||||||
{
|
{
|
||||||
return ModuleLoader::getModule('silverstripe/userforms')
|
$resource = ModuleLoader::getModule('silverstripe/userforms')->getResource('images/editabledropdown.png');
|
||||||
->getRelativeResourcePath('images/editabledropdown.png');
|
|
||||||
|
if (!$resource->exists()) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $resource->getURL();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSelectorField(EditableCustomRule $rule, $forOnLoad = false)
|
public function getSelectorField(EditableCustomRule $rule, $forOnLoad = false)
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\UserForms\Tests\Model\EditableFormField;
|
||||||
|
|
||||||
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
use SilverStripe\UserForms\Model\EditableFormField\EditableCountryDropdownField;
|
||||||
|
|
||||||
|
class EditableCountryDropdownFieldTest extends SapphireTest
|
||||||
|
{
|
||||||
|
public function testGetIcon()
|
||||||
|
{
|
||||||
|
$field = new EditableCountryDropdownField;
|
||||||
|
|
||||||
|
$this->assertContains('/images/editabledropdown.png', $field->getIcon());
|
||||||
|
}
|
||||||
|
}
|
@ -229,4 +229,11 @@ class EditableFormFieldTest extends FunctionalTest
|
|||||||
// The opposite method should be to return it to its original state, i.e. show it again
|
// The opposite method should be to return it to its original state, i.e. show it again
|
||||||
$this->assertSame('removeClass("hide")', $displayRules['opposite']);
|
$this->assertSame('removeClass("hide")', $displayRules['opposite']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetIcon()
|
||||||
|
{
|
||||||
|
$field = new EditableTextField;
|
||||||
|
|
||||||
|
$this->assertContains('/images/editabletextfield.png', $field->getIcon());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user