删除Yii Model中的属性集

I work with Yii 1.x integrated with an LDAP database and while I was developing an feature for external user access to IT resources: Domain (to authenticate Windows/Linux external users) and Wi-fi (access to use), or both.

I faced a scenario where I need to remove an attribute which I earlier set in the model: for security reasons, I populate the model with all data expect the main flags like sambaAcctFlags, disabledAccount and shadowExpire whom grant real access to resources: SAMBA in Domain and RUCKUS in Wi-fi.

The main problem is when I create a model record, I set the attribute disabledAccount - which when not there grants access to Wi-fi, but when its set the RUCKUS refuses auth - and now I cannot remove this value from model when the user has not selected the checkbox and so I tried to use unset($model->disabledAccount) and it didn't work. I have seen some suggestions that replace the variable with a null value but with my LDAP Yii' extensions, this will throw an LDAP error when saving the disabledAccount attribute.

Any light what could be done?

                $model->shadowexpire = time();
                $model->sambaAcctFlags = '[UD]';
                $model->disabledaccount = date('YmdHis\Z');

                foreach ($_POST['checkbox_acessos'] as $access ) {
                    switch ($access) {
                        case 'C': // Verify if the user has set Domain Access to user
                            $model->sambaAcctFlags = '[U]';   //Change flag from Deactivate to Activate
                            break;
                        case 'W': // Verify if the user has set Wi-fi to user
                            unset($model->disabledaccount); //this is the main problem**
                            echo "Wi-fi Granted!";
                            break;           
                    }
                }

                $model->shadowExpire = strtotime($validade->format('d-m-Y H:i:s'));
                // Date when Expire Unix based systems access

I can't get your problem correctly, your sentences were incomplete, anyway if you want to save the default value that you defined before in your database, replace unset method with unsetAttributes().

In this case:

$model->unsetAttributes(['disabledAccount']);