Last active
August 29, 2015 14:18
-
-
Save cfitz/87ec5cfa2bcd5f347949 to your computer and use it in GitHub Desktop.
form_fix_controller.rb
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
# | |
# 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