Skip to content
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

Support provided value in form helper #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

csm123
Copy link

@csm123 csm123 commented Aug 2, 2016

Some of my form fields have default values, like so:

= f.trix_editor :intro, value: ((@business.intro.present? && @business.intro) || "Default intro")

In this case, I want to pass the value of the form field explicitly. Rails' default form helpers allow this, but it did not work with the trix_editor helper. This PR enables it.

I'm not sure if more has to be done to support Formtastic.

@@ -36,7 +36,7 @@ def render
options = @options.stringify_keys
add_default_name_and_id(options)
options['input'] ||= dom_id(object, [options['id'], :trix_input].compact.join('_'))
trix_editor_tag(options.delete('name'), value_before_type_cast(object), options)
trix_editor_tag(options.delete('name'), (options['value'] || value_before_type_cast(object)), options)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you extract the value setting to a separate variable?

@maclover7
Copy link
Owner

Sorry for takin so long to get to this PR. If you can make the change requested and rebase, I'd be happy to merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants