# Calendardateselect + observe\_form?

**URL:** <https://www.ruby-forum.com/t/calendardateselect-observe-form/173242>\
**Category:** Rails\
**Created:** [August 5, 2009, 3:35pm UTC](https://www.ruby-forum.com/t/calendardateselect-observe-form/173242 "2009-08-05T15:35:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![trevoke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@trevoke](https://www.ruby-forum.com/u/trevoke)\
**Post date:** [August 5, 2009, 3:35pm UTC](https://www.ruby-forum.com/t/calendardateselect-observe-form/173242/1 "2009-08-05T15:35:20Z")

</div>

=begin  
I am using [Google Code Archive - Long-term storage for Google Code Project Hosting.](http://code.google.com/p/calendardateselect/) to make  
date-selection easier.  
This is my current code. I’d like the selection of a date to trigger the  
observe\_form and call the partial to be rendered.  
My current attempt is to update a hidden field within the form when a  
date is  
selected, because plain date selection did not seem to work.  
Did I just screw up the observe\_form / form\_remote\_tag setup?  
Is there a better option for date selection which will easily trigger  
the observe\_form?  
=end

## controllers/dictated\_exams\_controller.rb

class DictatedExamsController \< ApplicationController

def index  
@users = User.all  
@from = Date.new  
end

def filter\_widget  
text = “”  
params.each { |a, b| text \<\< “#{a} =\> #{b}   
”}  
render :text =\> text

end

end

## views/dictated\_exams/index.html
\<% form\_remote\_tag :html =\> {:id =\> 'input', :action =\> url\_for(:controller =\> "dictated\_exams", :action =\> "filter\_widget") } do || %\> \<%= collection\_select :widget\_user, :id, @users, :id, :name, { :prompt =\> true } %\> \<%= hidden\_field 'date', '' %\> \<%= calendar\_date\_select\_tag "calendar", Date.today, :time =\> false, :valid\_date\_check =\> "date \< (new Date()).stripTime()", :onchange =\> "date.value = $F(this)" %\> \<% end %\>

\<%= observe\_form :input,  
# The field to observe  
#:with =\> :id,  
# The input to validate  
:on =\> “onselect”,  
#:frequency =\> 0,  
# The frequency in seconds to watch for changes  
:url =\> {:action =\> ‘filter\_widget’, :controller =\> ‘dictated\_exams’ },  
# The action to call when changes occur  
:update =\> :filter\_counts  
# Name of the

 to update  
%\>

  

\<%= render :text =\> "Results will be listed here." %\>

---

<div class="post-metadata">

**Author:** ![trevoke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@trevoke](https://www.ruby-forum.com/u/trevoke)\
**Post date:** [August 10, 2009, 3:50pm UTC](https://www.ruby-forum.com/t/calendardateselect-observe-form/173242/2 "2009-08-10T15:50:05Z")

</div>

Because it’s Javascript making a change, I need to make it refresh  
regularly waiting for a change. On the bright side of things, if there  
is no change, it does NOT trigger anything, which is nice.
