lib/phlexi/field/builder.rb in phlexi-field-0.0.1 vs lib/phlexi/field/builder.rb in phlexi-field-0.0.2
- old
+ new
@@ -11,17 +11,19 @@
# @attr_reader [Object] object The object associated with the field.
# @attr_reader [Hash] attributes Attributes for the field.
# @attr_accessor [Object] value The value of the field.
class Builder < Structure::Node
include Phlex::Helpers
- include Options::Associations
- include Options::Attachments
- include Options::Descriptions
- include Options::Hints
+ include Options::Validators
include Options::InferredTypes
+ include Options::Multiple
include Options::Labels
include Options::Placeholders
+ include Options::Descriptions
+ include Options::Hints
+ include Options::Associations
+ include Options::Attachments
class DOM < Structure::DOM; end
class FieldCollection < Structure::FieldCollection; end
@@ -50,14 +52,14 @@
# @return [FieldCollection] The field collection.
def repeated(collection = nil, &)
self.class::FieldCollection.new(field: self, collection:, &)
end
- protected
-
def has_value?
- value.present?
+ attachment_reflection.present? ? value.attached? : (value.present? || value == false)
end
+
+ protected
def determine_initial_value(value)
return value unless value == NIL_VALUE
determine_value_from_object