Class: Flowbite::InputField
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Flowbite::InputField
- Defined in:
- app/components/flowbite/input_field.rb,
app/components/flowbite/input_field/url.rb,
app/components/flowbite/input_field/date.rb,
app/components/flowbite/input_field/file.rb,
app/components/flowbite/input_field/text.rb,
app/components/flowbite/input_field/email.rb,
app/components/flowbite/input_field/phone.rb,
app/components/flowbite/input_field/number.rb,
app/components/flowbite/input_field/select.rb,
app/components/flowbite/input_field/checkbox.rb,
app/components/flowbite/input_field/password.rb,
app/components/flowbite/input_field/textarea.rb,
app/components/flowbite/input_field/date_time.rb,
app/components/flowbite/input_field/radio_button.rb
Overview
A fully fledged form element for an attribute containing label, input field, error messages, helper text and whatever else is needed for a user-friendly input experience.
The input field is an important part of the form element that can be used to create interactive controls to accept data from the user based on multiple input types, such as text, email, number, password, URL, phone number, and more.
Usually you’d use one of the subclasses of this class which implement the different input types, like Text, Email, etc.
To render an input without labels or error messages etc, see Input instead and one of its subclasses.
Direct Known Subclasses
Checkbox, Date, DateTime, Email, File, Number, Password, Phone, RadioButton, Select, Text, Textarea, Url
Defined Under Namespace
Classes: Checkbox, Date, DateTime, Email, File, Number, Password, Phone, RadioButton, Select, Text, Textarea, Url
Instance Method Summary collapse
-
#errors ⇒ Array<String>
Returns the errors for attribute.
-
#initialize(attribute:, form:, class: nil, disabled: false, hint: nil, input: {}, label: {}, options: {}, size: :default) ⇒ InputField
constructor
A new instance of InputField.
- #input_component ⇒ Object
Constructor Details
#initialize(attribute:, form:, class: nil, disabled: false, hint: nil, input: {}, label: {}, options: {}, size: :default) ⇒ InputField
Returns a new instance of InputField.
118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'app/components/flowbite/input_field.rb', line 118 def initialize(attribute:, form:, class: nil, disabled: false, hint: nil, input: {}, label: {}, options: {}, size: :default) @attribute = attribute @class = Array.wrap(binding.local_variable_get(:class)) @disabled = disabled @form = form @hint = hint @input = input @label = label @object = form.object @options = || {} @size = size end |
Instance Method Details
#errors ⇒ Array<String>
Returns the errors for attribute
73 74 75 76 77 |
# File 'app/components/flowbite/input_field.rb', line 73 def errors return [] unless @object @object.errors[@attribute] || [] end |