mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
API CHANGE Read-only fields no longer include companion hidden fields (see pull request #399)
BUGFIX Remove legacy code and template which is never picked-up so that TextareaField becomes 'readonly' when it is transfered to readonly field. Change TextareaFieldTest test cases to address a 'readonly' textarea field displaying the special html characters correctly.
This commit is contained in:
parent
f6c8468d56
commit
3b3b515571
@ -57,24 +57,6 @@ class TextareaField extends FormField {
|
||||
);
|
||||
}
|
||||
|
||||
function getTemplate() {
|
||||
return ($this->isReadonly()) ? "{$this->template}_readonly" : $this->template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a readonly transformation on this field. You should still be
|
||||
* able to copy from this field, and it should still send when you submit
|
||||
* the form it's attached to.
|
||||
*
|
||||
* The element shouldn't be both disabled and readonly at the same time.
|
||||
*/
|
||||
function performReadonlyTransformation() {
|
||||
$clone = clone $this;
|
||||
$clone->setReadonly(true);
|
||||
$clone->setDisabled(false);
|
||||
return $clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a disabled transformation on this field. You shouldn't be able to
|
||||
* copy from this field, and it should not send any data when you submit the
|
||||
|
@ -1,2 +1,5 @@
|
||||
<span id="$ID"<% if extraClass %> class="$extraClass"<% end_if %>>$Value</span>
|
||||
<input $AttributesHTML>
|
||||
<% if isReadonly %>
|
||||
<span id="$ID"<% if extraClass %> class="$extraClass"<% end_if %>>$Value</span>
|
||||
<% else %>
|
||||
<input $AttributesHTML>
|
||||
<% end_if %>
|
||||
|
@ -1 +0,0 @@
|
||||
<span id="$ID" class="readonly$extraClass" name="$Name"><% if Value %>$Value<% else %><em>(<% _t('NONE', 'none') %>)</em><% end_if %></span>
|
@ -6,21 +6,32 @@ class TextareaFieldTest extends SapphireTest {
|
||||
* Quick smoke test to ensure that text is being encoded properly.
|
||||
*/
|
||||
function testTextEncoding() {
|
||||
$inputText = "This is my <text>These are some unicodes: äöü&<>";
|
||||
$inputText = "These are some unicodes: äöü";
|
||||
$field = new TextareaField("Test", "Test");
|
||||
$field->setValue($inputText);
|
||||
$this->assertContains('This is my <text>These are some unicodes: äöü&<>', $field->Field());
|
||||
$this->assertContains('These are some unicodes: äöü', $field->Field());
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick smoke test to ensure that text is being encoded properly in readonly fields.
|
||||
* Quick smoke test to ensure that text with unicodes is being displayed properly in readonly fields.
|
||||
*/
|
||||
function testReadonlyTextEncoding() {
|
||||
$inputText = "This is my <text>These are some unicodes: äöü&<>";
|
||||
function testReadonlyDisplayUnicodes() {
|
||||
$inputText = "These are some unicodes: äöü";
|
||||
$field = new TextareaField("Test", "Test");
|
||||
$field->setValue($inputText);
|
||||
$field = $field->performReadonlyTransformation();
|
||||
$this->assertContains('These are some unicodes: äöü', $field->Field());
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick smoke test to ensure that text with special html chars is being displayed properly in readonly fields.
|
||||
*/
|
||||
function testReadonlyDisplaySepcialHTML() {
|
||||
$inputText = "These are some special <html> chars including 'single' & \"double\" quotations";
|
||||
$field = new TextareaField("Test", "Test");
|
||||
$field = $field->performReadonlyTransformation();
|
||||
$field->setValue($inputText);
|
||||
$this->assertContains('This is my <text>These are some unicodes: äöü&<>', $field->Field());
|
||||
$this->assertContains('These are some special <html> chars including 'single' & "double" quotations', $field->Field());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user