Ruby on rails 如何为简单表单自定义富文本区域中的行数?

Ruby on rails 如何为简单表单自定义富文本区域中的行数?,ruby-on-rails,simple-form,ruby-on-rails-6,trix,actiontext,Ruby On Rails,Simple Form,Ruby On Rails 6,Trix,Actiontext,我正在使用SimpleForm 5.0.2和ActionText 我希望表单的主体字段是多行(比如说10行),但我不知道如何让它工作 这是我目前的尝试: <%= f.rich_text_area :body, class: 'form-control', name: "article-text", input_html: { rows: 10 }, placeholder: "Enter your article body here..." %> 都没有用 如何使其工作?它看起来像

我正在使用
SimpleForm 5.0.2
和ActionText

我希望表单的主体字段是多行(比如说10行),但我不知道如何让它工作

这是我目前的尝试:

<%= f.rich_text_area :body, class: 'form-control', name: "article-text", input_html: { rows: 10 }, placeholder: "Enter your article body here..." %>
都没有用


如何使其工作?

它看起来像是
富文本区域
只接受
:class
选项,因此
:input\u html
在这里什么也不做。但是因为高度是由CSS决定的,我们可以通过覆盖trix editor的默认最小高度CSS来实现您想要的

在app/assets/stylesheets/actiontext.scss中

trix-editor {
  &.customized-min-height {
    min-height: 15em;
  }
}
在您的视图文件中

f.rich_text_area :body, class: "form-control customized-min-height"

它看起来像是
rich\u text\u区域
只接受
:class
选项,因此
:input\u html
在这里什么也不做。但是因为高度是由CSS决定的,我们可以通过覆盖trix editor的默认最小高度CSS来实现您想要的

在app/assets/stylesheets/actiontext.scss中

trix-editor {
  &.customized-min-height {
    min-height: 15em;
  }
}
在您的视图文件中

f.rich_text_area :body, class: "form-control customized-min-height"

可以为trix编辑器设置最小高度属性,如下所示:

trix-editor {
  &.form-control {
    min-height: 20rem;
    height: auto;
  }
}

可以为trix编辑器设置最小高度属性,如下所示:

trix-editor {
  &.form-control {
    min-height: 20rem;
    height: auto;
  }
}

表单控件类是强制性的,但对我来说有问题。文本区域没有随文本垂直扩展,因此文本位于该区域之外。要修复它
高度:unset!重要的
@rdupz,我包括了
表单控件
,与原始问题一样,它不是强制性的。是的。当我说强制时,我的意思是它是由simple_form.Nice自动设置的!感谢您的澄清@rdupz表单控制类是强制性的,但对我来说有问题。文本区域没有随文本垂直扩展,因此文本位于该区域之外。要修复它
高度:unset!重要的
@rdupz,我包括了
表单控件
,与原始问题一样,它不是强制性的。是的。当我说强制时,我的意思是它是由simple_form.Nice自动设置的!感谢您的澄清@rdupz