Skip to content

Instantly share code, notes, and snippets.

@cfitz
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfitz/87ec5cfa2bcd5f347949 to your computer and use it in GitHub Desktop.
Save cfitz/87ec5cfa2bcd5f347949 to your computer and use it in GitHub Desktop.
form_fix_controller.rb
#
# Add this file to plugins/local/frontend/controllers/form_fix_controller.rb
# Obviously not a controller, but the naming convention is used to make sure that
# it loads.
#
module AspaceFormHelper
class FormContext
def label_and_date(name, opts = {})
field_opts = (opts[:field_opts] || {}).merge({
:class => "date-field form-control",
:"data-format" => "yyyy-mm-dd",
:"data-date" => Date.today.strftime('%Y-%m-%d'),
:"data-autoclose" => true,
:"data-force-parse" => false
})
if obj[name].blank? && opts[:default]
value = opts[:default]
else
value = obj[name]
end
opts[:col_size] = 4
date_input = textfield(name, value, field_opts)
label_with_field(name, date_input, opts)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment