Module: Formulary::HtmlForm::Labels
- Included in:
- Formulary::HtmlForm
- Defined in:
- lib/formulary/html_form/labels.rb
Instance Method Summary collapse
Instance Method Details
#label_for_field(field_name) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/formulary/html_form/labels.rb', line 2 def label_for_field(field_name) fields_for_name = document.css("*[name='#{field_name}']") if fields_for_name.empty? raise Formulary::FieldNotFoundError.new( "Cannot find label, field #{field_name} does not exist" ) end if fields_for_name.length > 1 labels_for_fieldset(fields_for_name) else label_for_single_field(fields_for_name.first) end end |