I am using moonlandsoft/yii2-tinymce in my Yii2 project.
I am using it according to their documentation.
use moonland\tinymce\TinyMCE;
echo TinyMCE::widget(['name' => 'text-content']);
$form->field($model, 'description')->widget(TinyMCE::className());
I don't know, how they are first rendering the widget and then loading the model into it.
It is not taking value and not validating on submit. It is required field of my table.
Controller :
public function actionUpdate($id) {
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->productId]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
Model :
public function rules()
{
return [
[['prodname','description'], 'required'],
];
}
View :
<div class="row" style="margin-top: 10px;">
<div class="col-md-12 col-sm-8 col-xs-12">
<?php
echo TinyMCE::widget(['name' => 'text-content']);
$form->field($model, 'description')->widget(TinyMCE::className());
?>
</div>
</div>