Skip to content

Commit

Permalink
refactored #remove_local_field_prop_unicode, and app/views/shared/fie…
Browse files Browse the repository at this point in the history
…lds/_text.haml input field
  • Loading branch information
kirykr committed Nov 11, 2022
1 parent 78b2e9f commit f5e3c92
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/helpers/custom_field_properties_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def remove_field_prop_unicode(field_props)
end

def remove_local_field_prop_unicode(field_props)
return field_props if field_props["local_label"].nil?
return field_props['label'] if field_props["local_label"].nil?

field = field_props["local_label"].gsub(/\&gt\;|\&lt\;|\&amp\;|\"/, '&lt;' => '<', '&gt;' => '>', '&amp;' => '&', '"' => '%22')
end
Expand Down
19 changes: 17 additions & 2 deletions app/views/shared/fields/_text.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,22 @@
%label.control-label{ class: required?(field_props['required'] || false) }
%abbr{ title: 'required' }= '*' if field_props['required'] || false
= label.html_safe
= f.input field_props['label'], required: (field_props['required'] || false), input_html: { class: field_props['className'], placeholder: format_placeholder(field_props['placeholder']), title: field_props['description'], name: "#{f.object_name}[#{remove_field_prop_unicode(field_props)}]", type: field_props['subtype'] , id: "#{f.object_name}[#{remove_field_prop_unicode(field_props)}]".parameterize, 'data-local-input': "#{f.object_name}[#{remove_local_field_prop_unicode(field_props)}]".parameterize }, label: false
= f.input field_props['local_label'], :as => :hidden, input_html: { name: "#{f.object_name}[Local_label #{remove_local_field_prop_unicode(field_props)}]", id: "#{f.object_name}[#{remove_local_field_prop_unicode(field_props)}]".parameterize }

%input{ name: "#{f.object_name}[#{remove_field_prop_unicode(field_props)}]",
"data-local-input": "#{f.object_name}[#{remove_local_field_prop_unicode(field_props)}]".parameterize,
title: field_props['description'],
type: field_props['subtype'],
class: field_props['className'],
placeholder: format_placeholder(field_props['placeholder']),
id: "#{f.object_name}[#{remove_field_prop_unicode(field_props)}]".parameterize,
required: (field_props['required'] || false) }/

.form-group.hidden
%input{ name: "#{f.object_name}[Local_label #{remove_local_field_prop_unicode(field_props)}]",
type: 'hidden',
subtype: 'text',
class: "form-control #{field_props['className']}",
id: "#{f.object_name}[#{remove_local_field_prop_unicode(field_props)}]".parameterize }/

%span.help-block
= field_message(field_props['label'], errors)

0 comments on commit f5e3c92

Please sign in to comment.