pantographe / view_component-form

Rails FormBuilder for ViewComponent
MIT License
216 stars 16 forks source link

Add label_text helper #102

Closed Spone closed 2 years ago

Spone commented 2 years ago

When developing custom components, it's sometimes useful to access the label string directly (without calling f.label). We could add a helper for this to our FieldComponent.

First draft, reusing this:

def label_text
  content ||= ActionView::Helpers::Tags::Translator.new(object, object_name, method_name, scope: "helpers.label").translate
  content ||= method_name.humanize
  content
end