Skip to content

Commit d4b72bb

Browse files
committed
Add human attribute name to field
1 parent 7068b96 commit d4b72bb

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

lib/superform/rails/components/label.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def field_attributes
1212
end
1313

1414
def label_text
15-
field.key.to_s.titleize
15+
field.human_attribute_name
1616
end
1717
end
1818
end

lib/superform/rails/field.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ def valid?
6161
not invalid?
6262
end
6363

64+
def human_attribute_name
65+
object.class.human_attribute_name key
66+
end
67+
6468
# HTML5 input type convenience methods - clean API without _field suffix
6569
# Examples:
6670
# field(:email).email(class: "form-input")

0 commit comments

Comments
 (0)