mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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:
parent
e3f15dba9e
commit
dec5c0ae60
@ -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.
|
||||
*/
|
||||
|
@ -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 <text><br />
|
||||
What's on a new-line?<br />
|
||||
These are some unicodes: äöü&<></span>
|
||||
<input type="hidden" name="Test" value="This is my &lt;text&gt;<br />
|
||||
What's on a new-line?<br />
|
||||
These are some unicodes: &auml;&ouml;&uuml;&amp;&lt;&gt;" />
|
||||
HTML
|
||||
, $field->Field());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user