i have following form_for - structure
<%= form_for group.new, url: what_to_do_files_path ,method: :get ,:validate => true |f| %> <div class="field"> <%=f.text_field :group_name, placeholder: "group name" %> </div> <%= button_tag :class => "btn btn-primary", :name => 'submit' %> submit <% end %> <button type="button" id="check_all"> check / uncheck all</button> lalalala <%end%>
model:
class arraygroup < activerecord::base attr_accessible :group_name, :user_id no_whitespace=/^[\s]+$/ validates :group_name, :format => { :with => no_whitespace} , :uniqueness => { :scope=> :user_id,:case_sensitive => false} validates_length_of :group_name, :minimum => 3 end
so, want able client-side-validate database group_name , user_id.
the problem user can specify name of group in text field , user_id 0 then. want specify user_id on own somehow, example <% f.user_id => @user_spec_id%>
, @user_spec_id predefined , points id of user. version doesnt work of course. have tried <% user_id => @user_spec_id%>
wrong.
thanks in advance
you looking hidden_field_tag
in view, following,
<%= hidden_field_tag #{f.object_name}[user_id], @user_spec_id %>
obviously inside form_for.
when submit form, see that, in params["group"] hash, added user_id.
Comments
Post a Comment