----------------- 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 << %() calHelper << %(\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 << %() calHelper << %(
#{text_field opt_for_txt[:obj_name],opt_for_txt[:attr_name], :value => convert_date(opt_for_txt[:data]), :style => "width:100px"}#{link_to_function image_tag("calendar",:border => "0"), url_java_script_part, {:name => opt_for_url[:anchor],:id => opt_for_url[:anchor]}}
) 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 %>