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

different date serializing when removing an element #24

Open
samtigall opened this issue Sep 8, 2023 · 2 comments
Open

different date serializing when removing an element #24

samtigall opened this issue Sep 8, 2023 · 2 comments
Assignees

Comments

@samtigall
Copy link

Hi!
I hope this is the correct place to report this issue.
I'm using the https://github.com/hofff/contao-calendarfield which uses the multicolumnwizard to manage disabled Dates for a calendar form input.

The multicolumnwizard is configured like this:

/**
 * Palettes
 */
$GLOBALS['TL_DCA']['tl_form_field']['palettes']['__selector__']  = array_merge($GLOBALS['TL_DCA']['tl_form_field']['palettes']['__selector__'], array('dateDirection', 'dateImage'));
$GLOBALS['TL_DCA']['tl_form_field']['palettes']['calendarfield'] = '{type_legend},type,name,label;{fconfig_legend},mandatory,placeholder,dateFormat,dateCssTheme,dateDirection,dateImage,dateDisabledWeekdays,dateDisabledDays,dateCustomConfiguration;{expert_legend:hide},class,value,dateParseValue,accesskey,tabindex;{template_legend:hide},customTpl;{invisible_legend:hide},invisible';

/**
 * Subpalettes
 */
$GLOBALS['TL_DCA']['tl_form_field']['subpalettes']['dateDirection_ownMinMax'] = 'dateDirectionMinMax';
$GLOBALS['TL_DCA']['tl_form_field']['subpalettes']['dateImage']               = 'dateImageSRC,dateImageSize';

[...]

$GLOBALS['TL_DCA']['tl_form_field']['fields']['dateDisabledDays'] = array
(
  'label'                   => &$GLOBALS['TL_LANG']['tl_form_field']['dateDisabledDays'],
  'inputType'               => 'multiColumnWizard',
  'eval'                    => array
  (
    'style'        => 'min-width: 100%;',
    'tl_class'     =>'clr',
    'minCount'        => 0,

    'columnFields' => array
    (
      'date' => array
      (
        'label'            => &$GLOBALS['TL_LANG']['tl_form_field']['dateDisabledDaysDate'],
        'exclude'          => true,
        'inputType'        => 'text',
        'eval'             => array('rgxp'=>'date', 'datepicker'=>true, 'tl_class'=>'wizard', 'style'=>'width: 300px;'),
      ),
      'active' => array
      (
        'label'            => &$GLOBALS['TL_LANG']['tl_form_field']['dateDisabledDaysActive'],
        'exclude'          => true,
        'inputType'        => 'checkbox'
      )
    )
  ),
  'sql'            => "blob NULL"
);

When I create 2+ entries (e.g. 08.09.2023, 09.09.2023 and 10.09.2023) and save it, it gets correctly serialized like this:
a:3:{i:0;a:2:{s:4:"date";i:1694124000;s:6:"active";s:1:"1";}i:1;a:2:{s:4:"date";i:1694210400;s:6:"active";s:0:"";}i:2;a:2:{s:4:"date";i:1694296800;s:6:"active";s:0:"";}}
note the timestamps.

When I remove an entry which is not the last one (e.g. 08.09.2023) it gets serialized like this:
a:2:{i:0;a:2:{s:4:"date";i:1694210400;s:6:"active";s:0:"";}i:1;a:2:{s:4:"date";s:10:"10.09.2023";s:6:"active";s:0:"";}}
Only the last date of the list gets serialized as string while the rest gets serialized as integer.

Kind regards,
Thomas

@zonky2
Copy link
Collaborator

zonky2 commented Apr 9, 2024

@samtigall
please add the version of MCW, Contao, PHP and calenderfield

@samtigall
Copy link
Author

@zonky2
MCW 3.6.3
Contao 4.13.37
PHP php:8.2-fpm
calnderfield 4.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants