Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chosen and multiple not working when 'dataContainer' => 'File', #42

Closed
benfolds opened this issue Mar 29, 2019 · 10 comments
Closed

chosen and multiple not working when 'dataContainer' => 'File', #42

benfolds opened this issue Mar 29, 2019 · 10 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@benfolds
Copy link

benfolds commented Mar 29, 2019

Case:
A multiselect filed at the tl_settings. In this case i want so select one or more content elements.

'selectElement' => [
                'label'     => &$GLOBALS['TL_LANG']['tl_settings']['classNames']['selectElement'],
                'inputType' => 'select',
                'default'   => 'all',
                'eval'      => [
                    'style'              => 'width:250px',
                    'chosen'             => true,
                    'multiple'           => true
                ],
                'options_callback'  => ['tl_settings_helper', 'getContentElements'],
                'reference' => &$GLOBALS['TL_LANG']['CTE'],
            ]

Behaviour
The field itself is working fine but when saving all setting inside the multicolumn wizard break. Guess the problem is saving an serialized array insinde a serialized array?

@zonky2
Copy link
Contributor

zonky2 commented Mar 29, 2019

wrapp code in tree ticks "```"

@discordier
Copy link
Member

This is a problem of DC_File then, isn't it?

@benfolds
Copy link
Author

hm, i guess the "normal" fields can not have nested serialized arrays, this could be only when using the multicolumnwizard, right? So maybe the array inside the array must be stored different? or you can escape the specialchars for the nested array when using this settings for this data container..

@discordier
Copy link
Member

No, there is also (at least) the module wizard widget and checkbox wizard in the core - do these work?

@benfolds
Copy link
Author

Just checked it:
The checkbox wizard design is broken inside the multicolumnwizard but the values will be stored correctly

@discordier
Copy link
Member

Design is another issue.

So I fear the problem is, that file uuids are stored as binary and this simply does not work correctly when writing it to a plain PHP file.
I am sorry but I fear there is nothing we can do here, as the serialized array is correct (from PHPs point of view) but the saving and loading of localconfig.php seems to not cope correctly with binary (which is not a big surprise as it is a text file).

On the other hand, localconfig.php and the system settings in the backend are considered deprecated since Contao 4.0 and all settings shall be migrated to settings files (config.yml and the like) over time and therefore you should search for a better point to save your data anyway, I suggest an own database table for user editable data or a static config on the file system (using the file path instead of the id) for data only to be manipulated by the system administrator and not to be manipulated.

@benfolds
Copy link
Author

Get your point with the localconfig.php, it's just easygoing to store system-wide info here :) It seems a bit too overengineered to store that in an own database...

But the problem there is not to store UUID's. I just have a dropdown of available content elements ...

@discordier
Copy link
Member

Ah sorry, misunderstood, I thought you were storing file pickers, I don't know why...

@zonky2 zonky2 added the bug Something isn't working label May 14, 2019
@zonky2 zonky2 added this to the 3.4.x milestone May 14, 2019
@Total-Reality
Copy link

I can't reproduce it with Contao 4.9 & MCW 3.4.9
However I tested it with options instead of "options_callback".

Please post your complete code.

This works:

$GLOBALS['TL_DCA']['tl_settings']['fields']['test'] = array
(
    'inputType' => 'multiColumnWizard',
    'eval'      => array
    (
        //'columnsCallback' => array('tl_mcw_test', 'getTestFields'),
        'columnFields' => array
        (
          'text' => array
          (
            'label'              => 'text',
            'default'            => 'Bla',
            'inputType'          => 'text',
            'eval'               => array('maxlength'=>5, 'style'=>'width:50px', 'readonly'=>true) //, 'nospace'=>true, 'trailingSlash'=>true
          ),
          'select' => array
          (
            'label'              => 'select',
            'default'            => 'b',
            'inputType'          => 'select',
            'options'            => array('s' => 'Sidney', 'b' => 'Bristol'),
            'eval'               => array('chosen' => true, 'multiple' => true, 'includeBlankOption' => true)
          ),
      ),
    )
);

@zonky2
Copy link
Contributor

zonky2 commented Jan 16, 2021

works fine

@zonky2 zonky2 closed this as completed Jan 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants