Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit 3b3b515571ba54cf8ca9c4dc1deaa82210e04d88 1 parent f6c8468
@normann normann authored chillu committed
View
18 forms/TextareaField.php
@@ -57,24 +57,6 @@ function getAttributes() {
);
}
- 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
View
7 templates/forms/FormField.ss
@@ -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 %>
View
1  templates/forms/TextareaField_Readonly.ss
@@ -1 +0,0 @@
-<span id="$ID" class="readonly$extraClass" name="$Name"><% if Value %>$Value<% else %><em>(<% _t('NONE', 'none') %>)</em><% end_if %></span>
View
23 tests/forms/TextareaFieldTest.php
@@ -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 &lt;text&gt;These are some unicodes: &auml;&ouml;&uuml;&amp;&lt;&gt;', $field->Field());
+ $this->assertContains('These are some unicodes: &auml;&ouml;&uuml;', $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 &lt;text&gt;These are some unicodes: &auml;&ouml;&uuml;&amp;&lt;&gt;', $field->Field());
+ $this->assertContains('These are some special &lt;html&gt; chars including &#039;single&#039; &amp; &quot;double&quot; quotations', $field->Field());
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.