Multi-Column Wizard Attribute

The Multi-Column Wizard (MCW) allows defining a variable input table with different input types such as text, checkboxes, and select in the columns — more about the MCW possibilities on Github or in the Contao Wiki.

With the extension attribute_tablemulti, the MCW can be used as an attribute in MetaModels. Note, however, that the MCW cannot be fully configured via the backend but requires a corresponding DCA configuration file. Additionally, it is not possible to search or filter by the stored values of the MCW attribute. The MCW values are stored in the database as a serialized array.

In addition to the mentioned version, there is also the multilingual counterpart as the extension attribute_translatedtablemulti.

The MCW attribute can be used, for example, to allow a variable number of inputs with different input types in an input mask. A simple example would be specifying multiple links with a text field for the URL, a text field for the link text, and a checkbox for the link target.

Installation and use consists of:

  • Installing the attribute via Composer from Github or via the Contao Manager

  • Customizing the DCA configuration file

Customizing the DCA Configuration File

The DCA configuration file <mm-table-name>.php or config.php must be placed at an appropriate location in the Contao installation or an existing file must be supplemented with the information. This can be done, for example, as:

  • contao/dca/<mm-table-name>.php

  • contao/config/config.php

or in a custom bundle in:

  • src/AppBundle/Resources/contao/dca/<mm-table-name>.php

  • src/AppBundle/Resources/contao/config/config.php

This file must be customized with an editor according to your own MetaModel parameters and desired fields — see Contao Wiki.

A configuration for the MetaModel “mm_my_table” with the MCW attribute “my_mcw” could look as follows:

 1<?php
 2// /contao/dca/mm_my_table.php
 3
 4$GLOBALS['TL_CONFIG']['metamodelsattribute_multi']['mm_my_table']['my_mcw'] = array(
 5   'minCount'     => 2,
 6   'maxCount'     => 4,
 7   'tl_class'     => 'clr w50',
 8   'columnFields' => array(
 9      'ts_client_os'     => array(
10         'label'     => 'My Options',
11         'exclude'   => true,
12         'inputType' => 'select',
13         'options'   => array(
14            'option1' => 'Option 1',
15            'option2' => 'Option 2',
16         ),
17         'eval'      => array('style' => 'width:250px', 'includeBlankOption' => true, 'chosen' => true)
18      ),
19      'ts_client_mobile' => array(
20         'label'     => 'My Checkbox',
21         'exclude'   => true,
22         'inputType' => 'checkbox',
23         'eval'      => array('style' => 'width:40px')
24
25      ),
26      'ts_extension'     => array(
27         'label'     => 'The Text Field',
28         'inputType' => 'text',
29         'eval'      => array('mandatory' => true, 'style' => 'width:115px')
30      ),
31   ),
32
33);

Note: The labels in “label” can also be included as a language array.

Clear the cache after making configuration changes!

View in the input mask:

img_input_mask

Note

From MM 2.4, the fileTree input type including multiple selection, gallery display, and sortability is also supported in both “MM MCW attributes”.

The configuration for image selection including custom sorting looks as follows:

 1<?php
 2// /contao/dca/mm_my_table.php
 3
 4$GLOBALS['TL_CONFIG']['metamodelsattribute_multi']['mm_my_table']['my_mcw'] = [
 5    'tl_class'     => 'clr',
 6    'minCount'     => 0,
 7    'columnFields' => [
 8        'col_title'     => [
 9            'label'     => 'Title',
10            'exclude'   => true,
11            'inputType' => 'text',
12            'eval'      => [
13                'style'         => 'width:100%',
14                'tl_class'      => 'my_class',
15                'wrapper_style' => 'width:50%',
16            ]
17        ],
18        'col_images' => [
19            'label'     => 'File selection',
20            'exclude'   => true,
21            'inputType' => 'fileTree',
22            'eval'      => [
23                'filesOnly'     => true,
24                'multiple'      => true,
25                'fieldType'     => 'checkbox',
26                'isGallery'     => true,
27                'orderField'    => 'col_images',
28                'extensions'    => \Contao\Config::get('validImageTypes'),
29                'isSortable'    => true,
30                'style'         => 'width:100%',
31                'tl_class'      => 'my_class',
32                'wrapper_style' => 'width:50%',
33            ]
34        ],
35    ],
36];