Class: Forms::Plain::Control

Inherits:
FormControl show all
Defined in:
lib/forms/plain/control.rb

Overview

The label + field + error/hint wrapper as a bare

, preserving FormControl's ordering contract.

Instance Method Summary collapse

Methods inherited from FormControl

#initialize

Constructor Details

This class inherits a constructor from Forms::FormControl

Instance Method Details

#view_templateObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/forms/plain/control.rb', line 8

def view_template
  div(**@options.except(:class), class: @options[:class]) do
    render Label.new(text: @label, for: @field_id, required: @required) if @label

    yield if block_given?

    if @error
      render FieldError.new(message: @error)
    elsif @hint
      render FieldHint.new(text: @hint)
    end
  end
end