我在 Yii2 项目中使用了moonlandsoft/yii2-tinymce。
我根据他们的文档使用它。
use moonland\tinymce\TinyMCE;
echo TinyMCE::widget(['name' => 'text-content']);
$form->field($model, 'description')->widget(TinyMCE::className());
我不知道,他们如何首先渲染小部件,然后将模型加载到其中。
它没有价值,也没有在提交时验证。这是我表的必填字段。
控制器 :
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,
]);
}
}
模型 :
public function rules()
{
return [
[['prodname','description'], 'required'],
];
}
看法 :
<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>