A
A
Alexander Laikov2017-03-10 18:14:44
Yii
Alexander Laikov, 2017-03-10 18:14:44

How to add value parameter in CKeditor?

Good afternoon.
How to add value parameter in CKeditor?
Am I using CKeitor by MiahailDev?
Or are there similar similar text editors?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2017-03-10
@Florens

How to add value parameter in CKeditor?
Can you be more specific about what value
Am I using CKeitor by MiahailDev?
I don't know, you know better what you are using
Or are there similar similar text editors?
I like imperavi:
https://github.com/vova07/yii2-imperavi-widget
https://imperavi.com/redactor/

D
Dmitry, 2017-03-10
@slo_nik

I do so

<?= $form->field($model, 'short_text')->widget(CKEditor::className(),[
        'editorOptions' => ElFinder::ckeditorOptions(['elfinder', 'path' => 'articles_files'], ['preset' => 'full', 'height' => 250]),
    ]) ?>

Without any value, when editing in the text area, the text that is recorded in the database is displayed.
ElFinder to attach a file to text.
PS
Completely looks like this.
In view
<?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'short_text')->widget(CKEditor::className(),[
        'editorOptions' => ElFinder::ckeditorOptions(['elfinder', 'path' => 'articles_files'], ['preset' => 'full', 'height' => 250]),
    ]) ?>

    <?//= $form->field($model, 'full_text')->textarea(['rows' => 6]) ?>
    <?= $form->field($model, 'full_text')->widget(CKEditor::className(),[
        'editorOptions' => ElFinder::ckeditorOptions(['elfinder', 'path' => 'articles_files'], ['preset' => 'full', 'height' => 250])
    ]) ?>

    <?php ActiveForm::end(); ?>

In a controller called ArticlesController. No extra models
public function actionUpdate($id)
    {
        $model = $this->findModel($id);

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['view', 'id' => $model->id]);
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    }

    protected function findModel($id)
    {
        if (($model = Articles::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question