Symfony2 TinymceBundle

Symfony2 TinymceBundle,tinymce,symfony,Tinymce,Symfony,我创建了一个ArticleController来呈现一个带有字段的表单:title(text)和content(textarea),在我将class=“tinymce”添加到模板中的textarea字段之前,一切都很正常。然后我得到这个错误: “名为='form[content]'的无效表单控件不可聚焦。” 我按照文档添加了“class”属性,编辑器在浏览器中呈现得很好,就在我提交表单时,我发现了错误 你知道这是什么原因吗? {{form_errors(form)} {{form_小部件(fo

我创建了一个ArticleController来呈现一个带有字段的表单:title(text)和content(textarea),在我将class=“tinymce”添加到模板中的textarea字段之前,一切都很正常。然后我得到这个错误: “名为='form[content]'的无效表单控件不可聚焦。” 我按照文档添加了“class”属性,编辑器在浏览器中呈现得很好,就在我提交表单时,我发现了错误

你知道这是什么原因吗?

{{form_errors(form)}
{{form_小部件(form.title)}
{{form_小部件(form.content,{'attr':{'class':'tinymce'}}}}
{{form_rest(form)}

显然,chrome在属性'required=“true”方面存在问题。


我在submit button输入字段中添加了'formnovalidate=“true”'属性,它工作正常

当WYSIWYG隐藏您的textarea,但textarea设置为必填字段时,会发生错误。构建表单时,可以在content textarea控件上设置'required'=>false,以禁用浏览器的必需检查

$builder->add("content", "textarea", array('required' => false));

tinyMCE通常会在
onsubmit
-事件期间更新隐藏文本区域的内容。 但是,当使用html5验证且任何输入无效时,不会触发此事件

因此,除非在html5验证开始之前强制更新textarea,否则您永远不会得到一个顶部带有tinyMCE的空且必需的textarea来正确验证


我为这个bug建立了一个解决方案,希望它能很快被合并到原始回购协议中:

我尝试了Musefan的建议,但只起了部分作用,但它让我尝试了一下

这是对我有用的东西。在Firefox10.0.1、IE9和Chrome17上测试

我正在设置
tinyMCE.activeEditor.getElement().value='test'
它可以是除
'
之外的任何值。不知道为什么是这样

tinyMCE.init({
    mode : "specific_textareas",
    editor_selector : "tinymce",

    setup : function(ed)
    {
        // This is needed when the textarea is required for html5
        ed.onInit.add(function(ed)
        {
                      tinyMCE.activeEditor.getElement().value = 'test'
        });
    },

});

基于穆塞凡斯的上述回应

我来这里是因为我使用简单表单、Twitter引导和tinymce rails。如果您使用的是tinymce rails,则需要编辑tinymce.yml文件中的注释行。您的最终文件应该与此类似

theme_advanced_toolbar_location: top 
theme_advanced_toolbar_align: left
theme_advanced_statusbar_location: bottom
theme_advanced_buttons3_add:
  - tablecontrols
  - fullscreen
plugins:
  - table
  - fullscreen
mode:
  - specific_textareas

是的,但我需要这是一个必填字段。我确信有一些方法可以要求字段不带属性,但是我找到了一种更简单的方法来修复这个google chrome bug,并且仍然保留所需的属性。无论如何,谢谢你:)
tinyMCE.init({
    mode : "specific_textareas",
    editor_selector : "tinymce",

    setup : function(ed)
    {
        // This is needed when the textarea is required for html5
        ed.onInit.add(function(ed)
        {
                      tinyMCE.activeEditor.getElement().value = 'test'
        });
    },

});
theme_advanced_toolbar_location: top 
theme_advanced_toolbar_align: left
theme_advanced_statusbar_location: bottom
theme_advanced_buttons3_add:
  - tablecontrols
  - fullscreen
plugins:
  - table
  - fullscreen
mode:
  - specific_textareas