Search code examples
ruby-on-rails-3formsformtastic

Formtastic: insert preloaded text in input field


How can I add a preloaded costant string in a classic input field in Formtastic?

I have searched a lot, but I haven't find how to resolve this.

For example I have this line of code in my form:

<%= f.input :url, :hint => "Url in the form of: http//www.mysite.com"  %>

and in the input field I want to preload the: "http://", so the user must fill only the remaining of the URL.


Solution

  • This should do what you want.

    <%= f.input :url, :hint => "Url in the form of: http//www.mysite.com", :input_html => { :value => "http://" }%>