Calling model methods even when the param is a not set

Hello,     I'm setting a checkbox values based on the return of a model field method. The way the method is set up - it only gets called when a checkbox value is set.

Here's the model code:

[code]   def within=(new_within)      @within = new_within == "1" || new_within == true || new_within == 'true' || new_within == 'on'   end [/code]

I would like that method to be called even when the checkbox is not set.

Thanks for any help anyone can provide.

Clem C

Could you provide me the check box script in view?

you can put additional params in form_tag

example :

<% from_tag bla...bla.., :within => true %>

...

<% end_from_tag %>

I hope it can answer yours. it will be directly executed each time the form_tag is run. What do you want this 'def within' is run for every time model is used or only in form_tag?

Visit Indonesia 2008 wrote:

Could you provide me the check box script in view?

you can put additional params in form_tag

example :

<% from_tag bla...bla.., :within => true %>

...

<% end_from_tag %>

I hope it can answer yours. it will be directly executed each time the form_tag is run. What do you want this 'def within' is run for every time model is used or only in form_tag?

Here's the checkbox code:

<input style="height:13px;" id="<%= search_obj %>_within" name="<%= search_obj %>[within]" type="checkbox" <%= !last_search[:within].to_s.blank? ? "checked='true'" : "" %> value="1"/>

Also, here's the form_remote_tag code:

<%= form_remote_tag(:url => {:controller => 'main', :action => action}, :html => { :id => "#{search_obj}_form", :action => url_for(:controller => 'main', :action => action) } ) %>

I would like to have the def within to be run everytime the form_tag is called.

I tried putting the :within => true in the form_remote_tag and had no results.

Thanks again for your help.