我使用前端插件将数据插入数据库。通过 Typo3 (TCA) 可以在后端查看记录。 问题:
如果前端表单中的文本区域存在中断,则会在记录中显示如下: 测试\r\n测试\r\n测试
我已经尝试过不同类型的转义、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']),
);
最佳答案
您需要对后端使用 TCA 类型“none”。但该字段不可编辑。
'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']),
);
关于php - Typo3 TCA 类型 "text"行/文本中断?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15073480/