ruby-on-rails - Rails 6.0.1 - Trix 编辑器参数未从表单传输

标签 ruby-on-rails trix

Trix 编辑器字段中添加或更改的数据不会提交/传输。

<%= form_with(model: @comment, local: true) do |form| %>
  <div class="form-group">
  <h4>Titel</h4>
  <%= form.text_field :header, class: "form-control border-top-0 border border-right-0 border-left-0 rounded-0 p-0" %>

  <br/>
  <h4>Inhalt</h4>
  <%= form.trix_editor :comment %>

  <%= form.text_field :tonie_id, value: tonie_id, hidden: true %>
  <%= form.text_field :user_id, value: current_user.id, hidden: true %>
  <%= form.check_box :private %> privater Kommentar

  <br/>

  <%= form.submit "speichern ",class: 'btn btn-success' %>
</div>
<% end %>

查看我的日志,我得到以下信息:

Parameters: {"authenticity_token"=>"xxxx", "tcomment"=>{"header"=>"title", "comment"=>"", "tonie_id"=>"49", "user_id"=>"1", "private"=>"0"}, "commit"=>"speichern "}

知道,可能出了什么问题吗?

最佳答案

这已经在这里讨论过:https://github.com/rails/rails/issues/37399

您可以通过手动为每个富文本字段分配 ID 来修复此问题。就像下面这样:

form.rich_text_area :first_description, id: 'trix_first_description'
form.rich_text_area :second_description, id: 'trix_second_description'
form.rich_text_area :third_description, id: 'trix_third_description'

希望这有帮助。

关于ruby-on-rails - Rails 6.0.1 - Trix 编辑器参数未从表单传输,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58790468/

相关文章:

html - 在 if ... else 语句的基础上添加额外的类

ruby-on-rails - ruby1.9.1 - ubuntu 9.10 x64 上的 sqlite3 问题(没有要加载的文件 -- sqlite3)

mysql - has_many :through multiple joins table

ruby-on-rails - Rails wikedPDF 错误 : PDF could not be generated

javascript - 防止默认粘贴

ruby-on-rails - 在 RSpec 测试中是否有 "it"的替代方案?

ruby-on-rails-6 - Trix使用rails actiontext添加纯html

ruby-on-rails - Rails - Capybara,从 trix-editor 填充隐藏字段

ruby-on-rails - 如何在没有 Active Storage 的情况下安装 Action Text?