将CKEditor与Play Framework结合使用

时间:2014-05-27 04:29:42

标签: playframework-2.0 ckeditor

如何将CKEditor与play框架一起使用?

我正在使用:

@helper.textarea(ProfileForm("aboutme"), '_label -> "About Me")</br>
            <script>
                CKEDITOR.replace( 'aboutme', {height: 164} );
            </script>

当删除编辑器脚本时,表单将加载textarea数据,但是当添加它时,textarea中的数据不会到达我的控制器。

1 个答案:

答案 0 :(得分:0)

我认为你想要渲染一个预填充的textarea。

要执行此操作,您应该在控制器中预填充表格,如下所示:

public static Result textArea() {
    Form<ProfileForm> profileForm = form(ProfileForm.class);
    ProfileForm profileForm_ = new ProfileForm();
    profileForm_.aboutMe = "hello";
    profileForm = profileForm.fill(profileForm_);
    return ok(views.html.textarea.render(profileForm));
}

这将使您的文本区域显示内容&#34; hello&#34;。

您的视图中的表单应如下所示:

@helper.form(action = routes.Application.textAreaSubmit()) {
    @helper.textarea(
        profileForm("aboutMe"),
        '_label -> "About me : ",
        'class -> "editable"
    )
    <input type="submit" value="Send" name="submit"/>
}
<script>
    CKEDITOR.replace( 'aboutMe', {height: 164} );
</script>

不要忘记将profileForm对象添加为视图标题中的参数:

@(profileForm: Form[beans.ProfileForm])