&I have been trying to insert a formatted entry into a text area using ZF2 and need line breaks. The consensus in blogs appears to be to use html entities to insert carriage returns and new lines.
I found a great explanation how to do this here: https://stackoverflow.com/a/8627926/1325365
This solution works really well when copied and pasted.
However when I use this solution in a ZF2 form the framework appears to alter what appears for instance I have the following code:
$this->add(array(
'name' => 'content',
'attributes' => array(
'type' => 'textarea',
'class' => 'wide',
'id' => 'content',
'value' => 'This is my statement one. This is my statement2'
),
'options' => array(
'label' => 'Content:',
),
));
The critical code has been changed when I view source. ZF2 has changed this to " ".
The changes to prevent XXS means the critical code displays literally.
Any suggestions how I change this behavior? One option is to insert the text using javascript, but this seems to be a round about route.
For a new line you can use this
'value' => 'This is my statement one.' . PHP_EOL . 'This is my statement2'