From d79c20c4f28f9b43f1bc105cb590d244c1b322f2 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 20 Jan 2008 14:01:02 +0000 Subject: [PATCH] Fixed: custom field selection is not saved when unchecking them all on project settings git-svn-id: http://redmine.rubyforge.org/svn/trunk@1083 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/projects_controller.rb | 1 - app/views/projects/_form.rhtml | 3 ++- test/functional/projects_controller_test.rb | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 2342e8074..30e7ef85f 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -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 diff --git a/app/views/projects/_form.rhtml b/app/views/projects/_form.rhtml index e29777af4..e63c929cc 100644 --- a/app/views/projects/_form.rhtml +++ b/app/views/projects/_form.rhtml @@ -35,10 +35,11 @@
<%=l(:label_custom_field_plural)%> <% for custom_field in @custom_fields %> <% end %> +<%= hidden_field_tag 'project[custom_field_ids][]', '' %>
<% end %> diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 61047079e..16eb2906e 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -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 -- 2.39.5