-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
be able to edit the initial value of the editor #40115
Conversation
How about accepting a non-nested |
You're absolutely right @georgeclaghorn, I've updated the pull request to have non-nested |
Hmm, I don’t think you have to do that. The As for how this is implemented, we can confine def render
# ...
@template_object.rich_text_area_tag(options.delete("name"), options.fetch("value") { editable_value }, options.except("value"))
end
def editable_value
value&.body.try(:to_trix_html)
end |
I've followed your recommendation and have cleaned up the commit as well to preserve history from the other lines. |
@@ -110,4 +110,18 @@ def form_with(*, **) | |||
"</form>", | |||
output_buffer | |||
end | |||
|
|||
test "form with rich text area having input_html" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
input_html
should be value
here.
This needs API doc updates here and a CHANGELOG entry. |
It’s a little gross, but you’ll want to call <%= f.rich_text_area :invitation_text, value: @training.invitation_text.body.presence&.to_trix_html ||
render(partial: 'personnel/trainings/invitation_text', locals: { training: @training }) %> Arguably |
Just tried it. Interestingly I get a NoMethodError: undefined method `to_trix_html' for #ActionText::RichText:0x00007fe33ae8fdf8 |
Note the added |
That makes @training.invitation_text.presence&.body&.to_trix_html |
@geoffharcourt : Awesome stuff, thx for your help. |
Summary
Hello rails team! I've been trying to add a rich text area that is not backed by a model. Here I'm proposing to add functionality with the same behaviour as
text_area
where we can add avalue
throughinput_html
would solve the problem.At the moment this snippet:
yields this:
With the changes in this pull-request, it should add the correct hidden_input
Other Information
Please let me know if there are other ways to do this currently or if there's better ways that I can improve the code