Style formatting in submit_tag / form tag helpers
I want to have the "Save" in bold but not "changes" in the below helper tag.
<%= submit_tag "Save changes", :action => "update", :id => @user %>
I am unable to put HTML in the string and call html_safe on it, eg "Save Changes".htm开发者_JAVA技巧l_safe.
How should I go about this?
The string "Save changes"
gets assigned to the value
attribute of the submit
tag created by the submit_tag
helper method. You can't put additional html within an html tag, which is what you're trying to do here. If you really want just the first word bolded, then you could consider creating a custom button using HTML and CSS and have it use Javascript to submit the form. Though you may need to fallback to using a normal submit button if your users don't have Javascript enabled.
精彩评论