platx/yii2-copy-attributes-behavior

This package is abandoned and no longer maintained. No replacement package was suggested.

Copies values to attributes from other attributes

Installs: 2 104

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

dev-master 2015-11-13 15:55 UTC

This package is not auto-updated.

Last update: 2020-10-16 21:08:28 UTC


README

Copies values to attributes from other attributes

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist platx/yii2-copy-attributes-behavior "*"

or add

"platx/yii2-copy-attributes-behavior": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your ActiveRecord by :

public function behaviors()
{
    return [
        'copy-attributes' => [
            'class' => '\platx\copyattributes\CopyAttributesBehavior',
            'clearTags' => true,
            'maxLength' => 160,
            'attributes' => [
                'share_title' => 'name',
                'share_content' => 'content_short',
            ],
        ]
    ];
}

Behavior configuration

  • clearTags: boolean, It determines whether to clear the attribute of html tags. Defaults to false.
  • maxLength: integer, Trim the text to the specified length. Defaults to false.
  • attributes: array, Array of attributes ( target attribute => source attribute). Defaults to null:
'attributes' => [
    'target_attribute' => 'source_attribute',
    'target_attribute2' => 'source_attribute2',
    ...
],