How to modify (not add) backend form fields by extension?

Hi. I was trying to modify by extension the default value of the send_invite boolean field in the User Plugin. I was able to set it to false like this:

use RainLab\User\Models\User as UserModel;
use RainLab\User\Controllers\Users as UsersController;

// in a plugin boot function:
UsersController::extendFormFields(function($form,$model,$context){
            if(!$model instanceof UserModel){
                return;
            }
            
            if($context == 'create'){
                $model->send_invite = false;
            }
           
        });

But I was wondering if there’s a way to modify it’s properties, and not only to change its value directly like this one.

Check out modules/backend/classes/FormField.php for methods you can call on the form field.

Here’s how you can uncheck it by default.

\RainLab\User\Controllers\Users::extendFormFields(function ($form, $model, $context) {
    if ($field = $form->getField('send_invite')) {
        $field->value('');
    }
});