From 854500401fb91ccb0dfc4ff4115adc90f1cefcdc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Fri, 11 Sep 2015 14:05:01 +0200 Subject: [PATCH] Auftrags-Controller: CVars: leere CVars bei neuen items anlegen und id merken --- SL/Controller/Order.pm | 5 +++++ templates/webpages/order/tabs/_row.html | 2 ++ 2 files changed, 7 insertions(+) diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 79ff2934f..83938509f 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -151,6 +151,11 @@ sub action_add_item { $new_attr{sellprice} = $part->sellprice if ! $item->sellprice; $new_attr{discount} = $cv_discount if ! $item->discount; + # add_custom_variables adds cvars to an orderitem with no cvars for saving, but + # they cannot be retrieved via custom_variables until the order/orderitem is + # saved. Adding empty custom_variables to new orderitem here solves this problem. + $new_attr{custom_variables} = []; + $item->assign_attributes(%new_attr); $self->order->add_items($item); diff --git a/templates/webpages/order/tabs/_row.html b/templates/webpages/order/tabs/_row.html index ca340ebf8..fc2776d13 100644 --- a/templates/webpages/order/tabs/_row.html +++ b/templates/webpages/order/tabs/_row.html @@ -74,6 +74,8 @@ [% L.hidden_tag('order.orderitems[].custom_variables[+].config_id', var.config.id) %] + [% L.hidden_tag('order.orderitems[].custom_variables[].id', var.id) %] + [% L.hidden_tag('order.orderitems[].custom_variables[].sub_module', var.sub_module) %] [% INCLUDE 'common/render_cvar_input.html' var_name='order.orderitems[].custom_variables[].unparsed_value' %] [%- IF (n % (MYCONFIG.form_cvars_nr_cols || 3)) == 0 %] -- 2.20.1