I am trying to populate a textarea
defined like this
$this->addElement('textarea', 'body', array(
'label' => $translate->translate('Contents:'),
'cols' => '80',
'rows' => '24',
'required' => true
));
from a database record. The record is a BLOB containing HTML text of pages, in UTF-8.
$form->populate(array(
// ...
'body' =>
str_replace("\\n", "\n",
html_entity_decode(
$page['body']
)
),
// ...
));
Unfortunately, when the length of the text is larger than 2934 bytes, the field is not populated at all. I tried setting maxlength
by issuing
'maxlength' => '4096',
but it seems to have no effect.
Now, from what I could find on the web, textarea
limits should be larger than 2934 bytes, more closer to 30-60 KB. Other than resorting to splitting the field into two separate form elements, how could I fix this problem?
Update It seems that the culprit was the character "ß", that is encoded in the database as two characters, "Ã�". The first occurence of that character is at the position 2934 within the text, so the second character in a two byte representation somehow breaks the field from receiving the text entirely.