Skip to content

Commit

Permalink
Replace all non-alphanumeric characters with underscores in custom us…
Browse files Browse the repository at this point in the history
…erdata html

Closes #474
  • Loading branch information
ChrisMacNaughton committed Nov 5, 2023
1 parent 21322d1 commit 16a99eb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/views/application/_custom_datum.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
<%= hidden_field_tag "custom_data[#{custom_datum.name}]", custom_datum.value || false %>
<%= check_box_tag "custom_data[#{custom_datum.name}]", true, custom_datum.value, disabled: disabled %>
<%- when 'array' %>
<div id="<%= custom_datum.name.gsub(' ', '_') %>">
<div id="<%= custom_datum.name.gsub(/[^0-9a-z]/i, '_') %>">
<%- if custom_datum.value %>
<%- custom_datum.value.each do |value| %>
<div class="input-group" id="input-group-<%= custom_datum.name.gsub(' ', '_') %>-<%= value.gsub('.', '_') %>">
<div class="input-group" id="input-group-<%= custom_datum.name.gsub(/[^0-9a-z]/i, '_') %>-<%= value.gsub(/[^0-9a-z]/i, '_') %>">
<%= text_field_tag "custom_data[#{custom_datum.name}][]", value, class: 'form-control', disabled: disabled %>

<%- unless disabled %>
<div class="input-group-append">
<button type="button" class="btn btn-danger" onclick="remove_element(this)" data-target="input-group-<%= custom_datum.name.gsub(' ', '_') %>-<%= value.gsub('.', '_') %>">Remove</button>
<button type="button" class="btn btn-danger" onclick="remove_element(this)" data-target="input-group-<%= custom_datum.name.gsub(/[^0-9a-z]/i, '_') %>-<%= value.gsub(/[^0-9a-z]/i, '_') %>">Remove</button>
</div>
<%- end %>
</div>
Expand All @@ -28,7 +28,7 @@
<%- end %>
</div>
<%- unless disabled %>
<button type="button" onclick="add_field(this)" data-name="custom_data[<%= custom_datum.name %>]" data-target="<%= custom_datum.name.gsub(' ', '_') %>" class="btn btn-dark btn-sm"><%= fa_icon 'plus' %> Add Item</button>
<button type="button" onclick="add_field(this)" data-name="custom_data[<%= custom_datum.name %>]" data-target="<%= custom_datum.name.gsub(/[^0-9a-z]/i, '_') %>" class="btn btn-dark btn-sm"><%= fa_icon 'plus' %> Add Item</button>
<%- end %>
<%- when 'integer' %>
<%= number_field_tag "custom_data[#{custom_datum.name}]", custom_datum.value, class: 'form-control', disabled: disabled %>
Expand Down

0 comments on commit 16a99eb

Please sign in to comment.