Yii2 actionUpdate doesn't save changed attribute

I’m using Yii2 on a Mac development platform running MAMP (PHP 7.3, MySQL 8, Apache 2.4).

I have successfully implemented 2Amigos’ Usuario module for user administration.

I have extended the User model by adding two attributes: status and accountExpire. Status is an integer and accountExpire is a string containing a date/time.

When I change the values for each in my form and click submit, the Status value changes in the database but the accountExpire does not.

The post looks like this (using Yii::warning() to print to log file):

2021-08-26 15:14:43 [::1][12][-][warning][application] AdminController: actionUpdate: before post load; post = Array
(
[_csrf] => iZA5KGEIzaF4nCJqG3VoyiUpdpTk3A9jG0drjvinX4DN1X9_KTmU9zv4ZT5fPAyfaWUZ7teVPjBWFx_Urc8R2Q==
[User] => Array
(
[status] => 1
[accountExpire] => 2021-09-30 18:10:00
[username] => barney
[email] => barney@fred.com
[password] =>
)
)

The dirty attributes array is:

2021-08-26 15:14:43 [::1][12][-][warning][application] AdminController: actionUpdate: after post load. Dirty attributes = Array
(
[status] => 1
[failedLoginNumber] => 0
)

The User array. Three dots … indicate where I redacted unrelated lines to shorten this post. Note the accountExpire entries; 2021-09-30 is the new date; 2025-03-08 is the old (original) date.

(
[created_at] => 1629900886
[password_hash] => $2y$13$LB7jHzSD6XpLfFFMOwvlEe.CH2ogdSy55ybOcWO1lWjx0TQV0htaq
[auth_key] => ziPYK_YOGLm6PkSm9TBMh8vC1R_jZ2Ho

[accountExpire] => 2021-09-30 18:10:00
[lastPasswordChange] =>

[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 315
[username] => barney
[password] => $2y$13$LB7jHzSD6XpLfFFMOwvlEe.CH2ogdSy55ybOcWO1lWjx0TQV0htaq
[salt] => LB7jHzSD6XpLfFFMOwvlEe
[email] => barney@fred.com

[accountExpire] => 2025-03-08 15:33:21

[gdpr_consent] => 0
[gdpr_consent_date] => 1890-01-01 00:00:00
[gdpr_deleted] => 0
)

[_oldAttributes:yii\db\BaseActiveRecord:private] => Array
    (
        [id] => 315
        [username] => barney
        [password] => $2y$13$LB7jHzSD6XpLfFFMOwvlEe.CH2ogdSy55ybOcWO1lWjx0TQV0htaq
        [password2] => 
        [salt] => LB7jHzSD6XpLfFFMOwvlEe
        [email] => barney@fred.com


[accountExpire] => 2025-03-08 15:33:21

[gdpr_consent] => 0
[gdpr_consent_date] => 1890-01-01 00:00:00
[gdpr_deleted] => 0
)
…lots more redacted…

Why isn’t the save() marking the accountExpire attribute dirty?

I fixed the problem with a work-around. In Usuario’s User/model/User – beforeSave(), I wrote:

    $currentPost = Yii::$app->request->post();
    this->setAttribute('accountExpire', $currentPost['User']['accountExpire']);

This ensures the dirtyAttribute flag is set for this attribute.

It would still be nice to know why the dirtyAttribute flag wasn’t set in the original problem, though. Any hints, anyone?