Skip to content

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.

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