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.

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]
)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.