API CHANGE: TextareaField doesn't have hidden value on read-only transformation. Added hidden fields in a way that doesn't break unit tests too severely (fixes #5056, thanks jshipman)

This commit is contained in:
Julian Seidenberg 2011-03-25 16:42:09 +13:00 committed by Ingo Schommer
parent e3f15dba9e
commit dec5c0ae60
2 changed files with 22 additions and 8 deletions

View File

@ -55,12 +55,24 @@ class TextareaField extends FormField {
'tabindex' => $this->getTabIndex(),
'readonly' => 'readonly'
);
$value = (($this->value) ? nl2br(htmlentities($this->value, ENT_COMPAT, 'UTF-8')) : '<i>(' . _t('FormField.NONE', 'none') . ')</i>');
$hiddenAttributes = array(
'type' => 'hidden',
'name' => $this->name,
'value' => $value,
'tabindex' => $this->getTabIndex()
);
return $this->createTag(
'span',
$attributes,
(($this->value) ? nl2br(htmlentities($this->value, ENT_COMPAT, 'UTF-8')) : '<i>(' . _t('FormField.NONE', 'none') . ')</i>')
);
$containerSpan = $this->createTag(
'span',
$attributes,
$value
);
$hiddenInput = $this->createTag('input', $hiddenAttributes);
return $containerSpan . "\n" . $hiddenInput;
} else {
$attributes = array(
'id' => $this->id(),
@ -88,10 +100,10 @@ class TextareaField extends FormField {
$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
* copy from this field, and it should not send any data when you submit the
* form it's attached to.
* The element shouldn't be both disabled and readonly at the same time.
*/

View File

@ -34,11 +34,13 @@ These are some unicodes: äöü&<>";
// Make sure that the field is smart enough to have its value set after being made readonly
$field->setValue($inputText);
$this->assertEquals(<<<HTML
<span id="Test" class="readonly" name="Test" readonly="readonly">This is my &lt;text&gt;<br />
What's on a new-line?<br />
These are some unicodes: &auml;&ouml;&uuml;&amp;&lt;&gt;</span>
<input type="hidden" name="Test" value="This is my &amp;lt;text&amp;gt;&lt;br /&gt;
What&#039;s on a new-line?&lt;br /&gt;
These are some unicodes: &amp;auml;&amp;ouml;&amp;uuml;&amp;amp;&amp;lt;&amp;gt;" />
HTML
, $field->Field());
}