CodeMirror
CodeMirror extension for Yii2, (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist kochiro/yii2-codemirror "*", (*4)
or add, (*5)
"kochiro/yii2-codemirror": "*", (*6)
to the require section of your composer.json
file., (*7)
Usage
Once the extension is installed, simply use it in your code by :, (*8)
field($file, 'description')->widget(CodeMirror::className(), [
'id' => $file->id,
'name' => '[description][]'.$id,
'value' => $file->description,
'mode' => $mode,
'htmlOptions' => [
"id"=>'description_'.$file->id,
"theme"=>'solarized dark' // set the theme based on the options in assets/theme, you must also include the corresponding css file in CodeMirrorAsset.php
]
]);
?>