Public feed #381753

Unnamed

public text v1 · immutable
Raw Edit
·published 2007-03-05 01:34 UTC
rendered paste body
----------------- APPLICATION HELPER
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
   def calendar_js_tag(opt_for_txt={},opt_for_url={})
    calHelper = %()
    calHelper << %(<table><tr>)
    calHelper << %(<td>#{text_field opt_for_txt[:obj_name],opt_for_txt[:attr_name],
                                    :value => convert_date(opt_for_txt[:data]),
                                    :style => "width:100px"}</td>\n)
    url_java_script_part = "cal.select(document.forms['#{opt_for_url[:form_name]}'].#{opt_for_txt[:obj_name]}_#{opt_for_txt[:attr_name]}," +
                           "'#{opt_for_url[:anchor]}','#{opt_for_url[:format]}')" 
    calHelper << %(<td>#{link_to_function image_tag("calendar",:border => "0"),
                                          url_java_script_part,
                                          {:name => opt_for_url[:anchor],:id => opt_for_url[:anchor]}}</td>)
    calHelper << %(</tr></table>)
   end
  
  def convert_date(date)
    return date.strftime("%m/%d/%Y") if !date.nil?
    return nil if date.nil?
  end
end

--------------- VIEW FILE
<%= form_tag( {:action => "update_documentation_contract"},{:name => "example"}) %>

 <%= calendar_js_tag(
              {:obj_name => 'example',:attr_name => 'date1',:data => @example.date1},
              {:form_name => 'example',:anchor => "anchor2",:format => 'MM/dd/yyyy'}
          )%>
<%= end_form_tag %>