Skip to content

Instantly share code, notes, and snippets.

@waldofe
Last active August 29, 2015 14:04
Show Gist options
  • Save waldofe/f7f867f956463531c296 to your computer and use it in GitHub Desktop.
Save waldofe/f7f867f956463531c296 to your computer and use it in GitHub Desktop.
Simple input form for time mask helper
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
@waldofe
Copy link
Author

waldofe commented Jul 17, 2014

Example:

= simple_input_time_form(f, :start_time, col_size: 3)

@hugomaiavieira
Copy link

@oswaldoferreira what is f?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment