My client side validation doesnt work somehow.
My html.erb:
<%= form_tag what_to_do_file_path, method: :get do %>
<%= submit_tag "Delete selected", :commit =>"delete" %>
<%= submit_tag "Pictures/Info/Raw Int", :commit =>"pictures" %>
<%= submit_tag "File normalize", :commit =>"pictures" %>
<%= form_for Group.new, :validate => true do |f| %>
<div class="field_label">
<%= f.label :group_name%>:
</div>
<div class="field">
<%=f.text_field :group_name %>
</div>
<%end%>
<% @files.each do |file| %>
<p><td> <%= check_box_tag "files[]", file.id %></td><%= file.file_name %></p>
<%=end%>
<%=end%>
My controller:
class Group< ActiveRecord::Base
include ActiveRecord::Validations
attr_accessible :group_name
validates :group_name,
:uniqueness => { :case_sensitive => false}
end
I what_to_do action I catch the ids of the files, that I want to group and params[:commit], meaning what I want to do with the files in this group.
Example
File 1, File 2, File 3.
I select all those Files and type a group name "Tripple" and select what I want to do with this group (either File normalize or whatever..)
(The name of the group should be validated in case this group already exists, in what_to_do I want to catch the ids of the files, params[commit] and the group name)
The validation works if I put a form_for outside form_tag, but I need to have it in form_tag because I want to catch in what_to_do action the name of the group.
How can I do it?
why aren't you using
form_for :something, url: what_to_do_file_path, method: :get
it is always encouraged to use form_for for this kinda tasks