PHPackages                             froala/yii2-froala-editor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. froala/yii2-froala-editor

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

froala/yii2-froala-editor
=========================

A beautiful WYSIWYG HTML text editor based on HTML5 technology. Cross browser, with mobile support, high performance and Retina Ready modern design.

5.0.1(2mo ago)109229.5k—3.5%40[5 issues](https://github.com/froala/yii2-froala-editor/issues)[5 PRs](https://github.com/froala/yii2-froala-editor/pulls)6MITPHPCI passing

Since Nov 18Pushed 1mo ago14 watchersCompare

[ Source](https://github.com/froala/yii2-froala-editor)[ Packagist](https://packagist.org/packages/froala/yii2-froala-editor)[ RSS](/packages/froala-yii2-froala-editor/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (101)Used By (6)

Yii Framework Froala WYSIWYG HTML Editor
========================================

[](#yii-framework-froala-wysiwyg-html-editor)

[![Packagist](https://camo.githubusercontent.com/dd6a1661e9d200441a0e2beaf91e2b042b0fd3d2ccf7897a129eb4a88ec1489c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66726f616c612f796969322d66726f616c612d656469746f722e737667)](https://packagist.org/packages/froala/yii2-froala-editor)[![Packagist](https://camo.githubusercontent.com/a6df3eb99347c8293ef57faf42bac0637765e20b70cdf253560f55b4fcc40ccc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f66726f616c612f796969322d66726f616c612d656469746f722e737667)](https://packagist.org/packages/froala/yii2-froala-editor)

> Yii 2 widget for Froala Wysiwyg editor.

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist froala/yii2-froala-editor

```

or add

```
"froala/yii2-froala-editor": "^3.2.5"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

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

```

```

or use with a model:

```

```

add Font-awesome cdn for font-awesome plugin

```

```

Upload example
--------------

[](#upload-example)

Using the basic Yii template make a new folder under /web/ called uploads.

For controler:

```
public function actionUpload() {
    $base_path = Yii::getAlias('@app');
    $web_path = Yii::getAlias('@web');
    $model = new UploadForm();

    if (Yii::$app->request->isPost) {
        $model->file = UploadedFile::getInstanceByName('file');

        if ($model->validate()) {
            $model->file->saveAs($base_path . '/web/uploads/' . $model->file->baseName . '.' . $model->file->extension);
        }
    }

    // Get file link
    $res = [
        'link' => $web_path . '/uploads/' . $model->file->baseName . '.' . $model->file->extension,
    ];

    // Response data
    Yii::$app->response->format = Yii::$app->response->format = Response::FORMAT_JSON;
    return $res;
}
```

For model:

```
namespace app\models;
use yii\base\Model;
use yii\web\UploadedFile;

/**
 * UploadForm is the model behind the upload form.
 */
class UploadForm extends Model
{
    /**
     * @var UploadedFile|Null file attribute
     */
    public $file;

    /**
     * @return array the validation rules.
     */
    public function rules()
    {
        return [
            [['file'], 'file']
        ];
    }
}
```

For the view:

```
