yii\db\ActiveRecord::loadDefaultValues PHP Method

loadDefaultValues() public method

You may call this method to load default values after creating a new instance: php class Customer extends \yii\db\ActiveRecord $customer = new Customer(); $customer->loadDefaultValues();
public loadDefaultValues ( boolean $skipIfSet = true )
$skipIfSet boolean whether existing value should be preserved. This will only set defaults for attributes that are `null`.
    public function loadDefaultValues($skipIfSet = true)
    {
        foreach (static::getTableSchema()->columns as $column) {
            if ($column->defaultValue !== null && (!$skipIfSet || $this->{$column->name} === null)) {
                $this->{$column->name} = $column->defaultValue;
            }
        }
        return $this;
    }