The logic makes sense in Rails. Something isn't quite clicking with DAL. 

class Event < ActiveRecord::Base
  # Sets the end_date to be +duration+ months after the start_date
  def duration=(duration)
    self.end_date = self.start_date + duration.to_i.months
  end
end

<%= form_for(@event) do |f| %>
  <%= f.date_select :start_date %>
  <%= f.select :duration, [["6 months", 6], ["1 year", 12], ["2 years", 
24]] %>
  <%= f.submit %>
<% end %>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to