heimrichhannot / contao-fieldpalette-bundle
FieldPalette is a contao widget like MultiColumnWizard with its own database table.
Installs: 13 979
Dependents: 9
Suggesters: 0
Security: 0
Stars: 5
Watchers: 6
Forks: 0
Open Issues: 1
Type:contao-bundle
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.7.3
- 0.7.2
- 0.7.1
- 0.7.0
- 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-feature/contao_5
- dev-contao5
This package is auto-updated.
Last update: 2025-03-11 14:52:18 UTC
README
If you're in search of an multi column input field and the storage of values in another table isn't an explicit requirement, we recommend to use Multi Column Editor Bundle instead, as it has less possible side effects and is more often updated due it's higher usage.
FieldPalette is a contao widget similar to MultiColumnWizard.
Unlike MultiColumnWizard, fields are stored flatly into tl_fieldpalette
table and synced with its parent field.
The fieldpalette configuration is based on Contao's Data Container Arrays.
FieldPalette Wizard - ListView
FieldPalette Wizard - Edit item
Technical instructions
Install
composer require heimrichhannot/contao-fieldpalette-bundle
You need to updated the contao database updated.
Getting started
FieldPalette comes with an custom input type fieldpalette
. The configuration for this input type is done in the fieldpalette
index of the field configuration array. You can customize your fieldpalette nearly as an "normal" dca configuration. When you finished setting up your fieldpalette input, you need to call the contao database tool to add the new fields to the table. See following example for a real world use case:
Default Setup (tl_fieldpalette
table)
This example shows the setup of an fieldpalette field within tl_news by using it within an subpalette. That (shortend) example is available within the module Contao News Leisure Bundle.
# contao/dca/tl_news.php $GLOBALS['TL_DCA']['tl_news']['fields']['venues'] = [ 'inputType' => 'fieldpalette', 'foreignKey' => 'tl_fieldpalette.id', 'relation' => ['type' => 'hasMany', 'load' => 'eager'], 'sql' => "blob NULL", 'fieldpalette' => [ 'config' => [ 'hidePublished' => false ], 'list' => [ 'label' => [ 'fields' => ['venueName', 'venueStreet', 'venuePostal', 'venueCity'], 'format' => '%s <span style="color:#b3b3b3;padding-left:3px">[%s, %s %s]</span>', ], ], 'palettes' => [ 'default' => 'venueName,venueStreet,venuePostal,venueCity', ], 'fields' => [ 'venueName' => [ 'label' => &$GLOBALS['TL_LANG']['tl_news']['venueName'], 'exclude' => true, 'search' => true, 'inputType' => 'text', 'eval' => ['maxlength' => 255, 'tl_class' => 'long'], 'sql' => "varchar(255) NOT NULL default ''", ], 'venueStreet' => [ 'label' => &$GLOBALS['TL_LANG']['tl_news']['venueStreet'], 'exclude' => true, 'search' => true, 'inputType' => 'text', 'eval' => ['maxlength' => 255, 'tl_class' => 'w50'], 'sql' => "varchar(255) NOT NULL default ''", ], 'venuePostal' => [ 'label' => &$GLOBALS['TL_LANG']['tl_news']['venuePostal'], 'exclude' => true, 'search' => true, 'inputType' => 'text', 'eval' => ['maxlength' => 32, 'tl_class' => 'w50'], 'sql' => "varchar(32) NOT NULL default ''", ], 'venueCity' => [ 'label' => &$GLOBALS['TL_LANG']['tl_news']['venueCity'], 'exclude' => true, 'filter' => true, 'search' => true, 'sorting' => true, 'inputType' => 'text', 'eval' => ['maxlength' => 255, 'tl_class' => 'w50'], 'sql' => "varchar(255) NOT NULL default ''", ], ], ], ];
Developers
Guides
DCA reference
Custom table set up
Working with fieldpalette records (copying (parent) records)
Working with fieldpalette model
The FieldPaletteModel
is not intended to be called directly and all custom methods are non static. We recommend to use the huh.fieldpalette.manager
service.
Example:
/** * @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');
Default model methods are still callable static. Custom method can also be called by creating a new model instance.
Widgets
Name | Description |
---|---|
fieldpalette | The FieldPaletteWizard renders the tl_fieldpalette items and provide crud functionality within its parent record (e.g. tl_news). |
Fields
tl_fieldpalette:
Name | Description |
---|---|
id | autoincrement unique identifiere |
pid | id of the parent entry |
ptable | parent table name (e.g. tl_news) |
pfield | parent field name (e.g. tl_news.venues) |
sorting | the sorting value |
published | the published state (1 = published) |
start | timestamp from where the element is published |
stop | timestamp until the element is published |
Form Callbacks
tl_fieldpalette:
Type | Description |
---|---|
oncreate_callback | Get fieldpalette key from request, check if the parent table is active within Fieldpalette Registry and set the pfield to tl_fieldpalette item. |
onsubmit_callback | Update/Sync parent fieldpalette item value (for example tl_news.venues) when tl_fieldpalette entries were updated. |
oncut_callback | Update/Sync parent fieldpalette item value (for example tl_news.venues) when tl_fieldpalette entries were sorted. |
ondelete_callback | Update/Sync parent fieldpalette item value (for example tl_news.venues) when tl_fieldpalette entries were deleted. |
Hooks
Name | Arguments | Description |
---|---|---|
loadDataContainer | $strTable | Register fields from parent datacontainer (like tl_news) to tl_fieldpalette and disable fieldpalette support from back end modules where no fieldpalette fields exists (see: initializeSystem Hook). |
initializeSystem | - | Enable tl_fieldpalette table within all back end modules. |
executePostActions | $strAction, DataContainer $dc | Add refreshFieldPaletteField ajax action that return the updated FieldPaletteWizard content. |
Restrictions
- only supports DC_Table DataContainers