2013-02-25 47 views
2

我使用前端插件将数据插入到数据库中。通过Typo3(TCA)记录可以在后端查看。 问题:Typo3 TCA类型“text”line-/textbreaks?

如果在textarea的从前端形成了这样的记录里面显示游: 测试\ r \ NTEST \ r \ NTEST

什么我已经尝试过不同类型的逃逸,nl2br,爆炸等等。 数据库字段应如何显示,以便中断显示正常?

下面是一些代码:

'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']), 
); 

回答

2

您需要使用TCA型 '无' 的后端。但是这个领域是不可编辑的。

'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, 
) 
), 

而您需要使用nl2br()函数,同时将值存储到数据库。

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