1

I am using magento calendar in ui component form just like the way it is in the link given here.Magento 2 - How to add the DateTime UI Component

It works fine when I add a new record, but when I edit a record , the current date and time is shown/picked by the calendar,indeed the calendar field must show the datetime record saved in the database. Thus when I edit any records , the datetime value gets reset and current datetime is saved in the database.Is this a known bug?. Any help would be appreciated.

Verdu
  • 1,730
  • 1
  • 17
  • 31

1 Answers1

0

I don't have the problem. It is not a bug.

It should be you set something wrong. I guess it could be the InstallSchema.php, when you create date column, notice don't use 'default' => Table::TIMESTAMP_INIT or 'default' => Table::TIMESTAMP_INIT_UPDATE.

Right example:

->addColumn(
    'start_time',
    Table::TYPE_TIMESTAMP,
    null,
    ['nullable' => false]
)

Wrong example:

->addColumn(
    'start_time',
    Table::TYPE_TIMESTAMP,
    null,
    ['nullable' => false, 'default' => Table::TIMESTAMP_INIT_UPDATE]
)
Key Shang
  • 3,415
  • 32
  • 58