在 app/inputs/rich_text_area_input.rb 中创建一个文件:
class RichTextAreaInput < SimpleForm::Inputs::Base
def input_html_classes
super.push('trix-content')
end
def input(wrapper_options = nil)
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
@builder.rich_text_area(attribute_name, merged_input_options)
end
end
在 application.scss 中:
//simple_form input for rich_text_area hight
trix-editor.form-control {
height: auto;
}
现在在 posts/_form.html.haml 你可以这样做:
= f.input :description, as: :rich_text_area
通过希望在某些时候 simple_form 必须将其添加到 master
来源1:https ://github.com/heartcombo/simple_form/issues/1638
来源2:https ://github.com/heartcombo/simple_form/pull/1646