How to access hidden fields

9 views
Skip to first unread message

manju

unread,
Apr 15, 2011, 7:04:16 AM4/15/11
to Ruby on Rails: Core
In my view I have on combo in that i load all subjects from
SubjectMaster table by that i got id and name of selected subject..
so I take two hidden fields name and code.
After this i want to store the name and code of that selected subject
in my subject table


<% form_remote_for @subject do |f| %>

<div> <label for="student_course">Select a Subject: </label></
div>
<div class="text-input-bg"><%=
f.select :subject_master_id ,@subjects.map {|b| [b.name, b.id] } ,
{:prompt => 'Select Subject'} %>
<%= f.hidden_field :name, :value => @subjects.name %>
<%= f.hidden_field :code, :value => @subjects.code %>

Colin Law

unread,
Apr 15, 2011, 4:23:55 PM4/15/11
to rubyonra...@googlegroups.com

These should be available in the params hash as params[:name] and
params[:code]. However I am a bit confused, is not @subjects an array
of subjects? If so then @subjects.name does not make sense.

Colin

Jason King

unread,
Apr 15, 2011, 4:35:41 PM4/15/11
to rubyonra...@googlegroups.com
This is a question/discussion for the rubyonrails-talk list.


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-co...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.


Reply all
Reply to author
Forward
0 new messages