PHP code example of nedarta / yii2-clean-html-behavior

1. Go to this page and download the library: Download nedarta/yii2-clean-html-behavior library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nedarta / yii2-clean-html-behavior example snippets


use nedarta\behaviors\CleanHtmlBehavior;

public function behaviors()
{
    return [
        [
            'class' => CleanHtmlBehavior::class,
            'attributes' => ['content', 'description'],
        ],
    ];
}

[
    'HTML.Allowed' => 'p,b,i,u,ul,ol,li,a[href],table,tr,td,th',
    'AutoFormat.RemoveEmpty' => true,
    'AutoFormat.RemoveEmpty.RemoveNbsp' => true,
    'AutoFormat.AutoParagraph' => false,
    'HTML.TargetBlank' => true,
    'Attr.AllowedFrameTargets' => ['_blank'],
    'HTML.Nofollow' => true,
    'CSS.AllowedProperties' => [],
]

public function behaviors()
{
    return [
        [
            'class' => CleanHtmlBehavior::class,
            'attributes' => ['content'],
            'htmlPurifierConfig' => [
                'HTML.Allowed' => 'p,b,i,u,ul,ol,li,a[href|title]',
            ],
        ],
    ];
}