ggzone
ggzone

Reputation: 3711

Typo3 TCA type "text" line-/textbreaks?

I use a frontend plugin to insert data into the database. Via Typo3 (TCA) the record can be viewed in Backend. The problem:

If there are breaks in the textarea from the frontend form its displayed inside the record like this: test\r\ntest\r\ntest

What i already tried are different kind of escaping, nl2br, explodes, and so on. How does the database-field should look like, so the breaks are displayed well?

Here is some code:

'note' => array(        
  'exclude' => 0,       
  'label' => 'LLL:EXT:mq_eventform/locallang_db.xml:tx_XYZ_data.note',      
  'config' => array(
    'type' => 'text',   
    'cols' => '30',
    'rows' => '5',  
  )
),

$field_values = array(
  'note' => mysql_real_escape_string($_REQUEST['note']),
);

Upvotes: 2

Views: 810

Answers (1)

osmanz
osmanz

Reputation: 481

You need to use TCA type 'none' for backend. But this field is not editable.

'note' => array(        
  'exclude' => 0,       
  'label' => 'LLL:EXT:mq_eventform/locallang_db.xml:tx_XYZ_data.note',      
  'config' => array(
    'type' => 'none',   
    'cols' => '30',
    'rows' => '5',
    'pass_content' => true, 
  )
),

And you need to use nl2br() function while storing value to database.

$field_values = array(
  'note' => nl2br($_REQUEST['note']),
);

Upvotes: 2

Related Questions