# File lib/app/helpers/form_helper.rb, line 45 def available_datepicker_options [:disabled, :altField, :altFormat, :appendText, :autoSize, :buttonImage, :buttonImageOnly, :buttonText, :calculateWeek, :changeMonth, :changeYear, :closeText, :constrainInput, :currentText, :dateFormat, :dayNames, :dayNamesMin, :dayNamesShort, :defaultDate, :duration, :firstDay, :gotoCurrent, :hideIfNoPrevNext, :isRTL, :maxDate, :minDate, :monthNames, :monthNamesShort, :navigationAsDateFormat, :nextText, :numberOfMonths, :prevText, :selectOtherMonths, :shortYearCutoff, :showAnim, :showButtonPanel, :showCurrentAtPos, :showMonthAfterYear, :showOn, :showOptions, :showOtherMonths, :showWeek, :stepMonths, :weekHeader, :yearRange, :yearSuffix] end
# File lib/app/helpers/form_helper.rb, line 54 def format_date(tb_formatted, format) new_format = translate_format(format) Date.parse(tb_formatted).strftime(new_format) end
Extending ActionView::Helpers::InstanceTag module to make Rails build the name and id Just returns the options before generate the HTML in order to use the same id and name (see to_input_field_tag mehtod)
# File lib/app/helpers/form_helper.rb, line 40 def get_name_and_id(options = {}) add_default_name_and_id(options) options end
# File lib/app/helpers/form_helper.rb, line 49 def split_options(options) tf_options = options.slice!(*available_datepicker_options) return options, tf_options end
Method that translates the datepicker date formats, defined in (docs.jquery.com/UI/Datepicker/formatDate) to the ruby standard format (www.ruby-doc.org/core-1.9.3/Time.html#method-i-strftime). This gem is not going to support all the options, just the most used.
# File lib/app/helpers/form_helper.rb, line 63 def translate_format(format) format.gsub!(/#{FORMAT_REPLACEMENTES.keys.join("|")}/) { |match| FORMAT_REPLACEMENTES[match] } end