heimrichhannot / contao-be_explanation-bundle
此包提供了一个简单的后端解释表单字段(inputType)。
2.5.0
2024-03-11 08:17 UTC
Requires
- php: ^7.4 || ^8.0
- contao/core-bundle: ^4.13 || ^5.0
Replaces
README
后端解释包
此包提供了一个简单的后端解释表单字段(inputType)。
技术说明
只需将字段添加到您的一些数据容器数组中,如下所示
use AppBundle\EventListener\Dca\TableListener; $GLOBALS['TL_DCA']['tl_table']['fields']['myExplanation'] = [ 'inputType' => 'explanation', 'eval' => [ 'text' => &$GLOBALS['TL_LANG']['tl_table']['explanation']['myExplanation'], // this is a string, not an array 'text_callback' => [TableListener::class, 'onTextCallback'], // a callback to dynamical generate text. Can also be a callable. 'class' => 'tl_info', // all contao message css classes are possible 'tl_class' => 'w50 long', 'collapsible' => true // If text is to long, if will be collapsed ] ];
文本回调
回调函数将获取从小部件构造函数中作为参数的 $attributes
数组,它包含小部件配置和当前数据容器。
示例
public function textCallback(array $attributes): string { $dc = $attributes["dataContainer"]; $text = $attributes["text"]; return "My new text"; }