Please can someone show me the correct syntax for a hidden field in forms, this is my code <%= start_form_tag :action => ''create'' %> <div class="form1"> <table width="auto" boader="8" cellspacing="5" cellpadding="5"> <% hidden_field ''line_item'', ''client_id'', :value => session[:client_id] %> <% hidden_field ''line_item'', ''product_id'', :value => 999999 %> <% hidden_field ''line_item'', ''sort_key'', :value => "saa" %> <% hidden_field ''line_item'', ''category'', :value => "adi" %> <% hidden_field ''line_item'', ''model'', :value => "additional item" %> <% hidden_field ''line_item'', ''prod_num'', :value => "999" %> <% hidden_field ''line_item'', ''image_s'', :value => "/images/til/aditem.jpg" %> <tr><td><class="depot-form" label for="quantity" >Quantity :</label></td><td><%= text_field ''line_item'', ''quantity'' %></td></tr> <tr><td><class="depot-form" label for="description" >Description :</label></td><td><%= text_area ''line_item'', ''description'', :cols=>"99", :rows=>"2" %></td></tr> <tr><td><class="depot-form" label for="unit_price" >Price :</label></td><td><%= text_field ''line_item'', ''unit_price'' %></td></tr> <tr><td></td></tr> </table> </div> <%= submit_tag ''Create Additional Item'' %> <%= end_form_tag %> Rails never complains but the record never appears. If I take the "hidden_field" lines out, a record is created. Thanks, Paul Thompson
On Sat, 2006-07-08 at 13:25 +1200, Paul Jonathan Thompson wrote:> Please can someone show me the correct syntax for a hidden field in > forms, this is my code > > <%= start_form_tag :action => ''create'' %> > > <div class="form1"> > > <table width="auto" boader="8" cellspacing="5" cellpadding="5"> > > <% hidden_field ''line_item'', ''client_id'', :value => session[:client_id] %> > <% hidden_field ''line_item'', ''product_id'', :value => 999999 %> > <% hidden_field ''line_item'', ''sort_key'', :value => "saa" %> > <% hidden_field ''line_item'', ''category'', :value => "adi" %> > <% hidden_field ''line_item'', ''model'', :value => "additional item" %> > <% hidden_field ''line_item'', ''prod_num'', :value => "999" %> > <% hidden_field ''line_item'', ''image_s'', :value => "/images/til/aditem.jpg" %> > <tr><td><class="depot-form" label for="quantity" >Quantity > :</label></td><td><%= text_field ''line_item'', ''quantity'' %></td></tr> > <tr><td><class="depot-form" label for="description" >Description > :</label></td><td><%= text_area ''line_item'', ''description'', > :cols=>"99", :rows=>"2" %></td></tr> > <tr><td><class="depot-form" label for="unit_price" >Price > :</label></td><td><%= text_field ''line_item'', ''unit_price'' > %></td></tr> > <tr><td></td></tr> > > </table> > </div> > > <%= submit_tag ''Create Additional Item'' %> > <%= end_form_tag %> > > Rails never complains but the record never appears. > If I take the "hidden_field" lines out, a record is created.---- I tend to use an "=" <%= hidden_field ... you probably want to enclose the html in brackets... <%= hidden_field ''controller'', ''column'', {:value => ''some value''} %> but I''m not certain that''s necessary Craig
you''re missing the ''='' <%= hidden_field ''line_item'', ''client_id'' %> On 7-Jul-06, at 9:25 PM, Paul Jonathan Thompson wrote:> Please can someone show me the correct syntax for a hidden field in > forms, this is my code > > <%= start_form_tag :action => ''create'' %> > > <div class="form1"> > > <table width="auto" boader="8" cellspacing="5" cellpadding="5"> > > <% hidden_field ''line_item'', ''client_id'', :value => session > [:client_id] %>
On Fri, 2006-07-07 at 18:41 -0700, Craig White wrote:> On Sat, 2006-07-08 at 13:25 +1200, Paul Jonathan Thompson wrote: > > Please can someone show me the correct syntax for a hidden field in > > forms, this is my code > > > > <%= start_form_tag :action => ''create'' %> > > > > <div class="form1"> > > > > <table width="auto" boader="8" cellspacing="5" cellpadding="5"> > > > > <% hidden_field ''line_item'', ''client_id'', :value => session[:client_id] %> > > <% hidden_field ''line_item'', ''product_id'', :value => 999999 %> > > <% hidden_field ''line_item'', ''sort_key'', :value => "saa" %> > > <% hidden_field ''line_item'', ''category'', :value => "adi" %> > > <% hidden_field ''line_item'', ''model'', :value => "additional item" %> > > <% hidden_field ''line_item'', ''prod_num'', :value => "999" %> > > <% hidden_field ''line_item'', ''image_s'', :value => "/images/til/aditem.jpg" %> > > <tr><td><class="depot-form" label for="quantity" >Quantity > > :</label></td><td><%= text_field ''line_item'', ''quantity'' %></td></tr> > > <tr><td><class="depot-form" label for="description" >Description > > :</label></td><td><%= text_area ''line_item'', ''description'', > > :cols=>"99", :rows=>"2" %></td></tr> > > <tr><td><class="depot-form" label for="unit_price" >Price > > :</label></td><td><%= text_field ''line_item'', ''unit_price'' > > %></td></tr> > > <tr><td></td></tr> > > > > </table> > > </div> > > > > <%= submit_tag ''Create Additional Item'' %> > > <%= end_form_tag %> > > > > Rails never complains but the record never appears. > > If I take the "hidden_field" lines out, a record is created. > ---- > I tend to use an "=" > > <%= hidden_field ... > > you probably want to enclose the html in brackets... > > <%= hidden_field ''controller'', ''column'', {:value => ''some value''} %> > but I''m not certain that''s necessary---- that doesn''t seem right... {value=''some value''} seems better Craig
Thanks for the help. This worked: <%= hidden_field ''line_item'', ''product_id'', :value => ''999999'' %> Craig, it did not need the curly brackets. Thanks to all, Paul On 08/07/06, Jodi Showers <jodi@nnovation.ca> wrote:> you''re missing the ''='' > > <%= hidden_field ''line_item'', ''client_id'' %> > > On 7-Jul-06, at 9:25 PM, Paul Jonathan Thompson wrote: > > > Please can someone show me the correct syntax for a hidden field in > > forms, this is my code > > > > <%= start_form_tag :action => ''create'' %> > > > > <div class="form1"> > > > > <table width="auto" boader="8" cellspacing="5" cellpadding="5"> > > > > <% hidden_field ''line_item'', ''client_id'', :value => session > > [:client_id] %> > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >