Last active
August 29, 2015 14:04
-
-
Save waldofe/f7f867f956463531c296 to your computer and use it in GitHub Desktop.
Simple input form for time mask helper
This file contains 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
def simple_input_time_form(f, attribute_time, opts = {}) | |
default_opts = { | |
value_field: f.object.send(attribute_time), | |
attr_error: attribute_time, | |
format_time: :time, | |
icon_time: 'fa-clock-o', | |
col_size: 4 | |
} | |
opts = default_opts.merge(opts) | |
%(<div class="col-md-#{opts[:col_size]}"> | |
<div class="form-group #{'has-error' if f.error opts[:attr_error]}"> | |
#{ f.label attribute_time } | |
<div class="input-group"> | |
#{ f.input_field attribute_time, as: :string, \ | |
value: l(opts[:value_field], format: opts[:format_time]), class: 'time-mask'} | |
<span class="input-group-addon"> | |
<span class="fa #{opts[:icon_time]}"> | |
</span> | |
</span> | |
</div> | |
#{ f.error opts[:attr_error] } | |
</div> | |
</div>).html_safe | |
end |
@oswaldoferreira what is f
?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: