Last active
December 14, 2015 15:38
-
-
Save henrik/5108817 to your computer and use it in GitHub Desktop.
Un-titlecase submit tag default value. E.g. "Create User" -> "Create user".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove titlecase from submit tag default value. | |
# E.g. "Create User" -> "Create user". | |
class ActionView::Helpers::FormBuilder | |
def submit_default_value_with_titlecase_removal | |
old = submit_default_value_without_titlecase_removal | |
model = if object.class.respond_to?(:model_name) | |
object.class.model_name.human | |
else | |
@object_name.to_s.humanize | |
end | |
old.sub(model, model.mb_chars.downcase) | |
end | |
alias_method_chain :submit_default_value, :titlecase_removal | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment