public function replaceTags($model)
    {
        if (isset($model->attributes)) {
            foreach ($model->attributes as $key => $attribute) {
                if (in_array($key, $this->dataAttributes)) {
                    $val = Yii::$app->formatter->asDatetime($model->{$key}, 'short');
                } else {
                    $val = $model->{$key};
                }

                $this->subject = str_replace('{' . $key . '}', $val, $this->subject);
                $this->user_subject = str_replace('{' . $key . '}', $val, $this->user_subject);
                $this->text = str_replace('{' . $key . '}', $val, $this->text);
                $this->user_text = str_replace('{' . $key . '}', $val, $this->user_text);
            }
        }

        $table = EmailDetailView::widget([
            'model' => $model,
            'attributes' => $model::$emailAttributes
        ]);

        $this->text = str_replace('{table}', $table, $this->text);
        $this->user_text = str_replace('{table}', $table, $this->user_text);

    }
public function replaceTags($model)
    {
        if (isset($model->attributes)) {
            foreach ($model->attributes as $key => $attribute) {
                if (in_array($key, $this->dataAttributes)) {
                    $val = Yii::$app->formatter->asDatetime($model->{$key}, 'short');
                } else {
                    $val = $model->{$key};
                }

                $this->subject = str_replace('{' . $key . '}', $val, $this->subject);
                $this->user_subject = str_replace('{' . $key . '}', $val, $this->user_subject);
                $this->text = str_replace('{' . $key . '}', $val, $this->text);
                $this->user_text = str_replace('{' . $key . '}', $val, $this->user_text);
            }
        }

        $table = EmailDetailView::widget([
            'model' => $model,
            'attributes' => $model::$emailAttributes
        ]);

        $this->text = str_replace('{table}', $table, $this->text);
        $this->user_text = str_replace('{table}', $table, $this->user_text);

    }
public function replaceTags ( $ model ) { if ( isset ( $ model -> attributes ) ) { foreach ( $ model -> attributes as $ key => $ attribute ) { if ( in_array ( $ key , $ this -> dataAttributes ) ) { $ val = Yii :: $ app -> formatter -> asDatetime ( $ model -> { $ key } , 'short' ) ; } else { $ val = $ model -> { $ key } ; } $ this -> subject = str_replace ( '{' . $ key . '}' , $ val , $ this -> subject ) ; $ this -> user_subject = str_replace ( '{' . $ key . '}' , $ val , $ this -> user_subject ) ; $ this -> text = str_replace ( '{' . $ key . '}' , $ val , $ this -> text ) ; $ this -> user_text = str_replace ( '{' . $ key . '}' , $ val , $ this -> user_text ) ; } } $ table = EmailDetailView :: widget ( [ 'model' => $ model , 'attributes' => $ model :: $ emailAttributes ] ) ; $ this -> text = str_replace ( '{table}' , $ table , $ this -> text ) ; $ this -> user_text = str_replace ( '{table}' , $ table , $ this -> user_text ) ; }
Replace tags by values in text and subject field
@param Form $model
@throws \yii\base\InvalidArgumentException
@throws \yii\base\InvalidConfigException
@throws \yii\base\InvalidParamException
@throws \Exception
Replace tags by values in text and subject field