form表单属性多选一并实现提交多条数据


<%form_for (@checkin) do|f|%>
<%=f.hidden_field :event_id, :value =>@event.id%>
<%=f.hidden_field :student_class_id, :value =>@student_class.id%>
<%=f.hidden_field :course_id, :value =>@course.id%>


<%if @team&&@team!=""%>

<%for team in @teams%>
<%if team.stu_reg_infs.size>0%>
<%sameevent=Event.find(:last,:conditions=>"team_id=#{team.id} and course_order=#{@event.course_order}")%>

<%end%>
<%for stu_reg_inf in team.stu_reg_infs%>





<%end%>
<%end%>


courses_stu_reg_infs=CoursesStuRegInf.find(:all,:conditions=>"student_class_id=#{params[:checkin][:student_class_id]} and course_id=#{params[:checkin][:course_id]} and (situation='已选' or situation='通过' or situation='不过')")
stu_reg_infs=[]
for courses_stu_reg_inf in courses_stu_reg_infs
stu_reg_infs< end

for stu_reg_inf in stu_reg_infs
if params["checkin"]["late_stu_reg_inf_#{stu_reg_inf.id}"] || params["checkin"]["leaver_stu_reg_inf_#{stu_reg_inf.id}"] || params["checkin"]["truant_stu_reg_inf_#{stu_reg_inf.id}"]|| params["checkin"]["kuaban_stu_reg_inf_#{stu_reg_inf.id}"]
checkin = Checkin.new
checkin.stu_reg_inf_id=stu_reg_inf.id
checkin.event_id=params[:checkin][:event_id]
checkin.student_class_id=params[:checkin][:student_class_id]
checkin.course_id=params[:checkin][:course_id]
if params["checkin"]["late_stu_reg_inf_#{stu_reg_inf.id}"]
checkin.late="迟到"
checkin.latetime=params["late#{stu_reg_inf.id}"]
end
if params["checkin"]["leaver_stu_reg_inf_#{stu_reg_inf.id}"]
checkin.leaver="早退"
checkin.leavertime=params["leaver#{stu_reg_inf.id}"]
end
if params["checkin"]["truant_stu_reg_inf_#{stu_reg_inf.id}"]
checkin.truant="旷课"
checkin.truantrecord=params["truant#{stu_reg_inf.id}"]
end
if params["checkin"]["kuaban_stu_reg_inf_#{stu_reg_inf.id}"]
checkin.kuaban="跨班"
checkin.kuabanrecord=params["kuaban#{stu_reg_inf.id}"]
end
checkin.save
end
end
redirect_to :action =>"show",:id=>params[:checkin][:event_id]


你可能感兴趣的:(RUBY)

学生名称迟到早退旷课跨班上
<%=team.name%><%=sameevent.starttime.strftime("%Y年%m月%d日%H时")%>
<%=stu_reg_inf.name%>
迟到
早退
旷课
跨班