diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index 71992354..6952738c 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -5,6 +5,7 @@ class OrdersController < ApplicationController before_filter :authenticate_orders + before_filter :remove_empty_article, only: [:create, :update] # List orders def index @@ -174,4 +175,8 @@ class OrdersController < ApplicationController notice.join(', ') end + def remove_empty_article + params[:order][:article_ids].reject!(&:blank?) if params[:order] and params[:order][:article_ids] + end + end diff --git a/app/views/orders/_form.html.haml b/app/views/orders/_form.html.haml index 48d776e1..3e978a19 100644 --- a/app/views/orders/_form.html.haml +++ b/app/views/orders/_form.html.haml @@ -48,6 +48,8 @@ %tr %td = check_box_tag 'checkall', "1", false, { 'data-check-all' => '#articleList' } + -# also when all are deselected, make sure this parameter is sent (controller removes empty values again) + = hidden_field_tag "order[article_ids][]", nil %td{:colspan => "6"}= t '.select_all' - if (@template_orders && !@template_orders.empty?)