Hi,
It isn’t working for me. Are there any good tutorials on putting
together
complex forms?
What I have is this:
Object A, in my example it is ExpenseReport. ExpenseReport contains
several
fields of its own like submitted_date, current_project, comments.
It also has a collection of LineItems which contains the amount,
establishment, comments.
A LineItem contains an ExpenseType which is another model object. In the
form, this would be represented by a drop down box. So the whole form
looks
something like this:
<% form_for :report, :url => { :action => ‘create’} do |form| %>
<label for="report_project">Name</label>
<%= text_field 'report', :project, :size => 40 %>
<label for="report_submit_date">Report Submitted on</label>
<%= datetime_select 'report', 'submit_date' %>
Report Line Item</legend>
<% fields_for :line_items do |line_item_form| %>
<% @line_items.each_with_index do |line_item, index| %>
<% fields_for :expense_categories do |expense_category| %>
<%= expense_category.collection_select(:id,
@expense_category, :id, :name) %>
<% end %>
<%= text_field :line_item_form, :amount, :index => index
%>
<% end %>
<% end %>
<label for="report_comments">Comments</label>
<%= text_area 'report', 'comments', :rows => 5, :cols => 60 %>
<%= submit_tag "Create" %>
<% end %>
The problem that I am having right now is twofold; first, when I use the
code listed below to extract the line_items and create those objects I
am
getting a ‘nil object’ error and second, in the params, there is only
one
listing for the expense_category instead of 5.
Anyone have ideas or tutorials they can point me to for this kind of
thing?
Thanks,
Chris
On 6/6/07, tmac [email protected] wrote:
<% end %>
None of that is tested but I >think< that is the general idea.
how
for a single expense. The form would also offer the user the chance to
–www.fuzzylizard.com
You know you’ve achieved perfection in design, Not when you have nothing
more to add, But when you have nothing more to take away.
–
www.fuzzylizard.com
You know you’ve achieved perfection in design, Not when you have nothing
more to add, But when you have nothing more to take away.
– Antoine de Saint-Exupery