目前simple_form不支持带有rich_text_area输入字段的ruby on rails 6 action_text。因此,目前我的输入字段在posts/_form.html.haml:中可以是这样的
= f.label :description
= f.rich_text_area :description
= f.error :description, class: 'text-danger'
如何使其作为= f.input :description
工作并具有丰富的文本区域?
在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
在应用程序中.css:
//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必须将其添加到主中
资料来源1:https://github.com/heartcombo/simple_form/issues/1638
资料来源2:https://github.com/heartcombo/simple_form/pull/1646