heimrichhannot / contao-fieldpalette-bundle
FieldPalette是一个类似于MultiColumnWizard的contao小部件,它有自己的数据库表。
Requires
- php: ^8.1
- contao/core-bundle: ^4.13 || ^5.2
- heimrichhannot/contao-utils-bundle: ^2.233.0 || ^3.0
- heimrichhannot/datatables: ^1.10
- heimrichhannot/datatables-additional: ^1.0
Requires (Dev)
- contao/manager-plugin: ^2.0
- contao/test-case: ^5.2
- friendsofphp/php-cs-fixer: ^2.2
- php-coveralls/php-coveralls: ^2.0
- php-http/guzzle6-adapter: ^1.0
- php-http/message-factory: ^1.0.2
- phpunit/phpunit: >=6.0 <6.5
- symfony/phpunit-bridge: ^3.2
Replaces
- dev-master
- 1.0.0-beta1
- 0.6.18
- 0.6.17
- 0.6.16
- 0.6.15
- 0.6.14
- 0.6.13
- 0.6.12
- 0.6.11
- 0.6.10
- 0.6.9
- 0.6.8
- 0.6.7
- 0.6.6
- 0.6.5
- 0.6.4
- 0.6.3
- 0.6.2
- 0.6.1
- 0.6.0
- 0.5.7
- 0.5.6
- 0.5.5
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.9
- 0.4.8
- 0.4.7
- 0.4.6
- 0.4.5
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.5
- 0.3.4
- 0.3.3
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.1
- 0.1.0
- dev-contao5
- dev-feature/refactor_field_loading
This package is auto-updated.
Last update: 2024-09-02 12:53:40 UTC
README
如果您正在寻找一个多列输入字段,并且存储值在另一个表中不是明确的要求,我们建议使用Multi Column Editor Bundle,因为它具有更少的可能副作用,并且由于使用率更高,更新频率也更高。
FieldPalette是一个与MultiColumnWizard类似的contao小部件。与MultiColumnWizard不同,字段被扁平地存储在tl_fieldpalette
表中,并与父字段同步。
FieldPalette配置基于Contao的数据容器数组。
技术说明
安装
composer require heimrichhannot/contao-fieldpalette-bundle
您需要更新contao数据库。
入门
FieldPalette包含一个自定义输入类型fieldpalette
。此输入类型的配置在字段配置数组中的fieldpalette
索引中完成。您可以像“正常”dca配置一样自定义FieldPalette。当您完成FieldPalette输入的设置后,您需要调用contao数据库工具将新字段添加到表中。以下示例展示了一个实际用例
默认设置(tl_fieldpalette
表)
此示例展示了如何通过在子调色板中使用它来在tl_news中设置一个fieldpalette字段。该(缩短的)示例可在模块Contao News Leisure Bundle中找到。
// src/Resource/contao/dca/tl_news.php (Bundle) // app/Resource/contao/dca/tl_news.php (Contao 4.4 Projekt) // contao/dca/tl_news.php (Contao 4.9 Projekt) $dc = &$GLOBALS['TL_DCA']['tl_news']; $fields = array ( 'venues' => array ( 'label' => &$GLOBALS['TL_LANG']['tl_news']['venues'], 'inputType' => 'fieldpalette', 'foreignKey' => 'tl_fieldpalette.id', 'relation' => array('type' => 'hasMany', 'load' => 'eager'), 'sql' => "blob NULL", 'fieldpalette' => array ( 'config' => array( 'hidePublished' => false ), 'list' => array ( 'label' => array ( 'fields' => array('venueName', 'venueStreet', 'venuePostal', 'venueCity'), 'format' => '%s <span style="color:#b3b3b3;padding-left:3px">[%s, %s %s]</span>', ), ), 'palettes' => array ( 'default' => 'venueName,venueStreet,venuePostal,venueCity', ), 'fields' => array ( 'venueName' => array ( 'label' => &$GLOBALS['TL_LANG']['tl_news']['venueName'], 'exclude' => true, 'search' => true, 'inputType' => 'text', 'eval' => array('maxlength' => 255, 'tl_class' => 'long'), 'sql' => "varchar(255) NOT NULL default ''", ), 'venueStreet' => array ( 'label' => &$GLOBALS['TL_LANG']['tl_news']['venueStreet'], 'exclude' => true, 'search' => true, 'inputType' => 'text', 'eval' => array('maxlength' => 255, 'tl_class' => 'w50'), 'sql' => "varchar(255) NOT NULL default ''", ), 'venuePostal' => array ( 'label' => &$GLOBALS['TL_LANG']['tl_news']['venuePostal'], 'exclude' => true, 'search' => true, 'inputType' => 'text', 'eval' => array('maxlength' => 32, 'tl_class' => 'w50'), 'sql' => "varchar(32) NOT NULL default ''", ), 'venueCity' => array ( 'label' => &$GLOBALS['TL_LANG']['tl_news']['venueCity'], 'exclude' => true, 'filter' => true, 'search' => true, 'sorting' => true, 'inputType' => 'text', 'eval' => array('maxlength' => 255, 'tl_class' => 'w50'), 'sql' => "varchar(255) NOT NULL default ''", ), ), ), ), ); $dc['fields'] = array_merge($dc['fields'], $fields);
开发者
指南
DCA参考
自定义表设置
处理fieldpalette记录(复制(父)记录)
处理fieldpalette模型
FieldPaletteModel
不打算直接调用,所有自定义方法都是非静态的。我们建议使用huh.fieldpalette.manager
服务。
示例
/** * @var ContainerInterface $container */ // Return a model instance (with default table) for usage with model method (like find methods) $container->get('huh.fieldpalette.manager')->getInstance()->findByPidAndTableAndField($item->id, 'tl_item', 'parentItem'); // Return a new model instance $container->get('huh.fieldpalette.manager')->createModel()->findByPidAndTableAndField($item->id, 'tl_item', 'parentItem'); // Return a new model instance with custom table $container->get('huh.fieldpalette.manager')->createModelByTable('tl_my_custom_table')->findByPidAndTableAndField($item->id, 'tl_item', 'parentItem');
默认模型方法仍然可以静态调用。也可以通过创建新的模型实例来调用自定义方法。
小部件
字段
tl_fieldpalette
表单回调
tl_fieldpalette
钩子
限制
- 仅支持DC_Table数据容器