]> source.dussan.org Git - redmine.git/commitdiff
Fixed: custom field selection is not saved when unchecking them all on project settings
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 20 Jan 2008 14:01:02 +0000 (14:01 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 20 Jan 2008 14:01:02 +0000 (14:01 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1083 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/projects_controller.rb
app/views/projects/_form.rhtml
test/functional/projects_controller_test.rb

index 2342e8074a02dce2f9c493e84bacbaf1cb927040..30e7ef85fd7bc774537625999eb1c79b0c0bfeaa 100644 (file)
@@ -113,7 +113,6 @@ class ProjectsController < ApplicationController
   # Edit @project
   def edit
     if request.post?
-      @project.custom_fields = IssueCustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
       if params[:custom_fields]
         @custom_values = ProjectCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
         @project.custom_values = @custom_values
index e29777af40124c9870934c9fce1381575aa59cf4..e63c929cc8ea954f183286c1577df46c17705612 100644 (file)
 <fieldset class="box"><legend><%=l(:label_custom_field_plural)%></legend>
 <% for custom_field in @custom_fields %>
     <label class="floating">
-       <%= check_box_tag "custom_field_ids[]", custom_field.id, ((@project.custom_fields.include? custom_field) or custom_field.is_for_all?), (custom_field.is_for_all? ? {:disabled => "disabled"} : {}) %>
+       <%= check_box_tag 'project[custom_field_ids][]', custom_field.id, ((@project.custom_fields.include? custom_field) or custom_field.is_for_all?), (custom_field.is_for_all? ? {:disabled => "disabled"} : {}) %>
        <%= custom_field.name %>
        </label>
 <% end %>
+<%= hidden_field_tag 'project[custom_field_ids][]', '' %>
 </fieldset>
 <% end %>
 <!--[eoform:project]-->
index 61047079e30c811bfdaeee40000f63eee3bd4bfa..16eb2906e76e19a17d532efd6edec006cad7a242 100644 (file)
@@ -71,7 +71,8 @@ class ProjectsControllerTest < Test::Unit::TestCase
   
   def test_edit
     @request.session[:user_id] = 2 # manager
-    post :edit, :id => 1, :project => {:name => 'Test changed name'}
+    post :edit, :id => 1, :project => {:name => 'Test changed name',
+                                       :custom_field_ids => ['']}
     assert_redirected_to 'projects/settings/ecookbook'
     project = Project.find(1)
     assert_equal 'Test changed name', project.name