skeeks\cms\relatedProperties\models\RelatedPropertiesModel::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 ($this->_properties as $property) {
            if (!$skipIfSet || $this->{$property->code} === null) {
                $this->{$property->code} = $property->defaultValue;
            }
        }
        return $this;
        /*foreach (static::getTableSchema()->columns as $column) {
              if ($column->defaultValue !== null && (!$skipIfSet || $this->{$column->name} === null)) {
                  $this->{$column->name} = $column->defaultValue;
              }
          }
          return $this;*/
    }