platx/yii2-copy-attributes-behavior Copies values to attributes from other attributes

behaviorcopyattributes

Yii 2 Copy Attributes Behavior

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',
    ...
],

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

No stable releases.

Comments



No stable releases.



MIT license
Stats
0 github stars & 0 github forks
0 downloads in the last day
0 downloads in the last 30 days
2104 total downloads