本文介绍了Trix 编辑器验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通过 Rails 视图助手使用 Trix 编辑器.
Using Trix editor via Rails view helpers.
= form.rich_text_area :description, class: 'form-control', placeholder: 'Description'
对描述进行一些模型必需"验证.
Have some model 'required' validation for description.
使用 field_with_errors
包装字段的正常 Rails 行为没有发生.
The normal Rails behavior of wrapping fields with field_with_errors
is not happening.
有没有人设法让 Trix 和正常的 Rails 验证行为协同工作?
Has anyone managed to get Trix and the normal Rails validation behavior to work together?
推荐答案
最终以这种方式修复..
Ended up fixing this way..
- if job.errors[:description].count > 0
.form-with-errors
= form.rich_text_area :description, class: 'form-control', placeholder: 'Description'
.invalid-feedback.d-block
- job.errors[:description].each do |error|
= error
还有……
.form-with-errors {
trix-editor {
border-color: #dc3545;
}
}
这篇关于Trix 编辑器验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!