@param \yii\base\Model $model

@param string $attribute
320462
public function validateAttribute( $model, $attribute ) {

        $serviceList = $this->getSynchonizer()->getServiceList();

        if ( $model->hasProperty( $attribute ) ) {
            if ( ! is_array( $model->$attribute ) ) {
                $this->addError( $model, $attribute, Yii::t( 'SyncSocial', 'Attribute "{attribute}" must be array', [
                    'attribute' => $attribute
                ] ) );
            } else {
                foreach ( $model->$attribute as $service ) {
                    if ( ! in_array( $service, $serviceList ) ) {
                        $this->addError( $model, $attribute, Yii::t( 'SyncSocial', 'Service list has wrong value' ) );
                    }
                }
            }
        }

    }
1330927
public static function activeUneditableField($model, $attribute, $htmlOptions = array())
    {
        parent::resolveNameID($model, $attribute, $htmlOptions);
        $value = parent::resolveValue($model, $attribute);
        TbArray::removeValues(array('name', 'id'), $htmlOptions);
        return self::uneditableField($value, $htmlOptions);
    }
65840
public function renderInput ($model, $attribute)
    {
        Html::addCssClass($this->chooseButtonClass, "btn {$this->_hashVar}");
        $eles = [];
        $eles[] = Html::activeTextInput($model, $attribute, ['class' => 'form-control']);
        $eles[] = Html::tag('span', Html::button('选择图片', $this->chooseButtonClass), ['class' => 'input-group-btn']);

        return Html::tag('div', implode("\n", $eles), ['class' => 'input-group']);
    }
255942
public static function getInstance(Model $model, $attribute)
    {
        foreach ($model->behaviors as $behavior) {
            if ($behavior instanceof self && $behavior->attribute == $attribute) {
                return $behavior;
            }
        }

        throw new InvalidCallException('Missing behavior for attribute ' . VarDumper::dumpAsString($attribute));
    }
1141883
public function haveRecord($model, $attributes = [])
    {
        /** @var $record \yii\db\ActiveRecord  * */
        $record = \Yii::createObject($model);
        $record->setAttributes($attributes, false);
        $res = $record->save(false);
        if (!$res) {
            $this->fail("Record $model was not saved");
        }
        return $record->primaryKey;
    }
1027281
public function rangeField($model, $attribute, $htmlOptions = array())
    {
        return $this->createInput(TbHtml::INPUT_TYPE_RANGE, $model, $attribute, $htmlOptions);
    }
296144
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);

    }
1320564
public function copyForUpdateTo( $model, $attributes = [] ) {

		foreach ( $attributes as $attribute ) {

			$model->setAttribute( $attribute, $this->getAttribute( $attribute ) );
		}
	}
716502
public function run($id, $attribute)
    {
        $model = $this->findModel($this->modelClass, $id);

        if (!$model->hasAttribute($attribute)) {
            throw new InvalidConfigException("Attribute doesn't exist.");
        }

        if ($model->$attribute == $this->onValue) {
            $model->$attribute = $this->offValue;
        } else {
            $model->$attribute = $this->onValue;
        }

        if ($this->preProcess && is_callable($this->preProcess, true)) {
            call_user_func($this->preProcess, $model);
        }

        if ($model->save(true, [$attribute])) {
            if ($this->setFlash) {
                Yii::$app->session->setFlash('success', $this->flashSuccess);
            }
        } else {
            if ($this->setFlash) {
                Yii::$app->session->setFlash('error', $this->flashError);
            }
        }

        if (Yii::$app->request->getIsAjax()) {
            Yii::$app->end();
        }

        if (!empty($this->redirect)) {
            return $this->controller->redirect($this->redirect);
        }

        return $this->controller->redirect(Yii::$app->request->getReferrer());
    }
601166
public static function createForModel($model, $attributes)
    {
        $model = static::makeForModel($model, $attributes);

        $model->save();

        return $model;
    }
8792
public function setAttribute($attribute, $value){
        if($attribute === 'table'){
            $this->_table = $value;
        }
        elseif($attribute === 'pk'){
            $this->_pk = $value;
        }
        elseif($attribute === 'relations'){
            $this->_relations = $value;
        }
        
        return $this;
    }
950047
public function validateUrl ($attribute)
		{
			if (!$this->hasErrors())
			{
				if (filter_var($this->$attribute, FILTER_VALIDATE_URL) === false)
					$this->addError($attribute, Yii::tr('{attribute} is not a valid URL.', [ 'attribute' => $this->name ], 'setting'));
			}
		}
1207840
protected function cleanAttributes(CleansAttributes $model)
    {
        $dirty = array_keys($model->getDirty());

        $invalidColumns = array_diff($dirty, $model->getColumnListing());

        foreach ($invalidColumns as $column) {
            unset($model->{$column});
        }
    }
1224071
public function validateAttribute($model, $attribute)
    {
        $countries = [];
        if ($this->country !== null) {
            $countries = [$this->country];
        } elseif ($this->countryAttribute !== null) {
            $countries = [$model->{$this->countryAttribute}];
        } elseif (is_array($this->countries) && count($this->countries) > 0) {
            $countries = $this->countries;
        }

        if (count($countries) <= 0) {
            $countries = self::getPhoneUtil()->getSupportedRegions();
        }

        foreach ($countries as $country) {
            try {
                $number = self::getPhoneUtil()->parse($model->$attribute, $country);

                if (self::getPhoneUtil()->isValidNumberForRegion($number, $country)) {
                    if ($this->format) {
                        $model->$attribute = self::getPhoneUtil()->format($number, PhoneNumberFormat::INTERNATIONAL);
                    }

                    $this->_successValidation = true;
                    break;
                }
            } catch (NumberParseException $e) {
                $this->addError($model, $attribute, $this->numberParseExceptionMessage);
            }
        }

        if (!$this->_successValidation) {
            $this->addError($model, $attribute, $this->notValidPhoneNumberMessage);
        }

        return $this->_successValidation;
    }
61670
public function newModel($attributes = [], $model = null)
    {
        $model = (class_exists($model) ? $model : $this->schema->entryModel());

        if (! is_subclass_of($model, $base = Model::class)) {
            throw new InvalidArgumentException("The given model class '{$model}' must extend the base model class '{$base}'");
        }

        return new $model($attributes, $this->builder->newInstance());
    }
107182
protected function timeCorrection($model, $attribute)
    {//echo __METHOD__."(model,'$attribute')";var_dump($model->$attribute);
        $resultFormat = 'Y-m-d H:i';
        $dateFormats = [
            'Y-m-d H:i',
            'Y-m-d G:i',
            'Y-m-j H:i',
            'Y-m-j G:i',
            'Y-n-d H:i',
            'Y-n-d G:i',
            'Y-n-j H:i',
            'Y-n-j G:i',
            //'Y-m-d', 'Y-m-j', 'Y-n-d', 'Y-n-j', // do not use - will add current time, not 00:00
        ];

        // correct if empty time
        //$model->$attribute = rtrim($model->$attribute, " :");
        $needCorrection = true;
        if (':' == substr($model->$attribute, -1)) {
            $model->$attribute = rtrim($model->$attribute, ':');
            $model->$attribute .= '00:00';
            $needCorrection = false;
        }

        foreach($dateFormats as $dateFormat) {
            $datetime = \DateTime::createFromFormat($dateFormat, $model->$attribute);
            if (!empty($datetime)) break;

        }
        if ($needCorrection && !empty($datetime) && !empty($model->timezoneshift)) {
            $unixDatetime = $datetime->getTimestamp();
            $unixDatetime += 60 * intval($model->timezoneshift);
            $datetime->setTimestamp($unixDatetime);
            $model->$attribute = $datetime->format($resultFormat);
        }//var_dump($model->$attribute);exit;
    }
688306
protected function takeAttributeFromDOM($attribute)
    {
        switch ($attribute->localName) {
        case 'relationship':
            $this->_relationship = $attribute->nodeValue;
            break;
        case 'type':
            $this->_type = $attribute->nodeValue;
            break;
        default:
            parent::takeAttributeFromDOM($attribute);
        }
    }