Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Make the date_picker form helper to handle nested attribute indexes correctly

Dombi Attila13ece2c0f26c
diff --git a/lib/tabular_form_builder.rb b/lib/tabular_form_builder.rb
index de3a0c6f254..b22633dd45a 100644
--- a/lib/tabular_form_builder.rb
+++ b/lib/tabular_form_builder.rb
@@ -94,7 +94,13 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
input_options[:class] << ' -error'
end
- inputs = { value: @object.public_send(field), id: field_id(field), name: field_name(field) }
+ @object_name.sub!(/\[\]$/, "") || @object_name.sub!(/\[\]\]$/, "]")
+
+ inputs = {
+ value: @object.public_send(field),
+ id: field_id(field, index: options[:index]),
+ name: field_name(field, index: options[:index])
+ }
if options.dig(:data, :'remote-field-key')
inputs['remote-field-key'] = options.dig(:data, :'remote-field-key')
diff --git a/modules/costs/app/views/hourly_rates/_rate.html.erb b/modules/costs/app/views/hourly_rates/_rate.html.erb
index 979ee2ec1e5..ac1630cfc24 100644
--- a/modules/costs/app/views/hourly_rates/_rate.html.erb
+++ b/modules/costs/app/views/hourly_rates/_rate.html.erb
@@ -44,6 +44,7 @@ See COPYRIGHT and LICENSE files for more details.
<td>
<label class="hidden-for-sighted" for="<%= "#{id_prefix}_valid_from" %>"><%= Rate.human_attribute_name(:valid_from) %></label>
<%= rate_form.date_picker :valid_from,
+ index: id_or_index,
class: 'date costs-date-picker op-datepicker-modal_fill_space',
no_label: true,
no_field_container: true %>