views:

317

answers:

1

I want to remove the ":" from the output of the rails time_select helper. The helper seems to output this automatically when the minutes select box is built.

Any ideas?

Thanks!

+4  A: 

The output from those helpers are usually just strings, so you should be able to say:

<%= time_select("post", "sunrise").gsub(/:/, ' ') %>

[Edit] Turns out a cleaner solution is to just say:

<%= time_select("post", "sunrise", :time_separator => "" %>
Terry
this solution is OK, but I was hoping to be able to pass some parameter into the build_select method. the reason is i have a plugin that overrides the way rails handles the time_select helper. the code is here: http://github.com/tamoyal/simple_time_select/blob/91de19740ce23db240f78085ada29c30e42bf1ef/lib/simple_time_select.rb , i cannot find any good documentation on the build_select method
Tony
sorry, but do you see lines 32 and 33 of that code snippet? why not just remove the colons from there, between #{ampm_hour} and #{minute_padded}? would that do what you want?
Terry
those are the colons in the time values, for example "12:45". the problem i have is the select automatically puts a colon outside of the select box....because usually you have a separate select field for hours and minutes. for example, <select>hh...</select> : <select>mm...</select> ..so i need to remove the colon that is automatically printed outside of the select box
Tony
ahh, gotcha. sorry for the misunderstanding. i don't even think gsub will do what you want, then, since that's screw up the 12:45. try passing a :time_separator to options, like:<%= time_select("post", "sunrise", :time_separator => "") %>that work?
Terry
sweet...thanks!
Tony