PHPackages                             heimrichhannot/contao-fieldpalette - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. heimrichhannot/contao-fieldpalette

Abandoned → [heimrichhannot/contao-fieldpalette-bundle](/?search=heimrichhannot%2Fcontao-fieldpalette-bundle)Contao-module[Utility &amp; Helpers](/categories/utility)

heimrichhannot/contao-fieldpalette
==================================

FieldPalette is a contao widget like \[MultiColumnWizard\] (https://github.com/menatwork/MultiColumnWizard) with its own database table.

1.4.10(7y ago)43.9k[1 issues](https://github.com/heimrichhannot/contao-fieldpalette/issues)4LGPL-3.0+PHPPHP ~5.4 || ~7.0

Since Jan 25Pushed 7y ago5 watchersCompare

[ Source](https://github.com/heimrichhannot/contao-fieldpalette)[ Packagist](https://packagist.org/packages/heimrichhannot/contao-fieldpalette)[ Docs](https://github.com/heimrichhannot/contao-fieldpalette)[ RSS](/packages/heimrichhannot-contao-fieldpalette/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (5)Versions (58)Used By (4)

FieldPalette
============

[](#fieldpalette)

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](https://docs.contao.org/books/api/dca/index.html).

[![alt fieldpalette wizard](./docs/img/fieldpalette_wizard.jpg)](./docs/img/fieldpalette_wizard.jpg)*FieldPalette Wizard - ListView*

[![alt fieldpalette edit](./docs/img/fieldpalette_edit.jpg)](./docs/img/fieldpalette_edit.jpg)*FieldPalette Wizard - Edit item*

Technical instructions
----------------------

[](#technical-instructions)

### Default Setup (`tl_fieldpalette` table)

[](#default-setup-tl_fieldpalette-table)

This example shows the setup of an fieldpalette field within tl\_news by using it within an subpalette. That example is available within the module \[heimrichhannot/contao-plus\] ([https://packagist.org/packages/heimrichhannot/contao-news\_plus](https://packagist.org/packages/heimrichhannot/contao-news_plus)).

```
#/system/modules/[MyModule]/dca/tl_news.php

$dc = &$GLOBALS['TL_DCA']['tl_news'];

/**
 * Selectors
 */
$dc['palettes']['__selector__'][] = 'addVenues';

/**
 * Subpalettes
 */
$dc['subpalettes']['addVenues'] = 'venues';

/**
 * Fields
 */
$arrFields = array
(
	// venue
	'addVenues'           => array
	(
		'label'     => &$GLOBALS['TL_LANG']['tl_news']['addVenues'],
		'exclude'   => true,
		'inputType' => 'checkbox',
		'eval'      => array('submitOnChange' => true),
		'sql'       => "char(1) NOT NULL default ''",
	),
	'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 [%s, %s %s]',
				),
			),
			'palettes' => array
			(
				'default' => 'venueName,venueStreet,venuePostal,venueCity,venueCountry,venueSingleCoords,venuePhone,venueFax,venueEmail,venueWebsite,venueText',
			),
			'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 ''",
				),
				'venueCountry'      => array
				(
					'label'     => &$GLOBALS['TL_LANG']['tl_news']['venueCountry'],
					'exclude'   => true,
					'filter'    => true,
					'sorting'   => true,
					'inputType' => 'select',
					'options'   => System::getCountries(),
					'eval'      => array('includeBlankOption' => true, 'chosen' => true, 'tl_class' => 'w50'),
					'sql'       => "varchar(2) NOT NULL default ''",
				),
				'venueSingleCoords' => array
				(
					'label'         => &$GLOBALS['TL_LANG']['tl_news']['venueSingleCoords'],
					'exclude'       => true,
					'search'        => true,
					'inputType'     => 'text',
					'eval'          => array('maxlength' => 64),
					'sql'           => "varchar(64) NOT NULL default ''",
					'save_callback' => array
					(
						array('tl_news_plus', 'generateVenueCoords'),
					),
				),
				'venueText'         => array
				(
					'label'     => &$GLOBALS['TL_LANG']['tl_news']['venueText'],
					'exclude'   => true,
					'search'    => true,
					'inputType' => 'textarea',
					'eval'      => array('rte' => 'tinyMCE', 'tl_class' => 'clr'),
					'sql'       => "text NULL",
				),
			),
		),
	),
);

$dc['fields'] = array_merge($dc['fields'], $arrFields);

```

### Custom table setup (e.g. `tl_member_address`)

[](#custom-table-setup-eg-tl_member_address)

In order to use Fieldpalette with your own table, create a Data Container Array that extends from `$GLOBALS['TL_DCA']['tl_fieldpalette']`, as the following example describes.

```
