Class: EasyAdmin::Layouts::Nodes::FieldNode
- Inherits:
-
BaseNode
- Object
- BaseNode
- EasyAdmin::Layouts::Nodes::FieldNode
show all
- Defined in:
- lib/easy_admin/layouts/nodes/field_node.rb
Overview
Node representing a field to be rendered
Instance Attribute Summary
Attributes inherited from BaseNode
#attributes, #children, #metadata, #visible_if
Instance Method Summary
collapse
Methods inherited from BaseNode
#[], #[]=, #accept, #add_child, #children?, #node_type, #visible?
Constructor Details
#initialize(name, attributes = {}) ⇒ FieldNode
Returns a new instance of FieldNode.
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/easy_admin/layouts/nodes/field_node.rb', line 6
def initialize(name, attributes = {})
super(attributes)
@field_name = name.to_sym
@attributes[:as] ||= nil @attributes[:label] ||= nil @attributes[:readonly] ||= false
@attributes[:required] ||= false
@attributes[:hint] ||= nil
@attributes[:placeholder] ||= nil
@attributes[:wrapper_class] ||= nil
end
|
Instance Method Details
#field_name ⇒ Object
18
19
20
|
# File 'lib/easy_admin/layouts/nodes/field_node.rb', line 18
def field_name
@field_name
end
|
#field_options ⇒ Object
Get all field options for rendering
51
52
53
|
# File 'lib/easy_admin/layouts/nodes/field_node.rb', line 51
def field_options
@attributes.except(:visible_if, :metadata)
end
|
#field_type ⇒ Object
22
23
24
|
# File 'lib/easy_admin/layouts/nodes/field_node.rb', line 22
def field_type
@attributes[:as]
end
|
#hint ⇒ Object
38
39
40
|
# File 'lib/easy_admin/layouts/nodes/field_node.rb', line 38
def hint
@attributes[:hint]
end
|
#label ⇒ Object
26
27
28
|
# File 'lib/easy_admin/layouts/nodes/field_node.rb', line 26
def label
@attributes[:label]
end
|
#placeholder ⇒ Object
42
43
44
|
# File 'lib/easy_admin/layouts/nodes/field_node.rb', line 42
def placeholder
@attributes[:placeholder]
end
|
#readonly? ⇒ Boolean
30
31
32
|
# File 'lib/easy_admin/layouts/nodes/field_node.rb', line 30
def readonly?
@attributes[:readonly]
end
|
#required? ⇒ Boolean
34
35
36
|
# File 'lib/easy_admin/layouts/nodes/field_node.rb', line 34
def required?
@attributes[:required]
end
|
#wrapper_class ⇒ Object
46
47
48
|
# File 'lib/easy_admin/layouts/nodes/field_node.rb', line 46
def wrapper_class
@attributes[:wrapper_class]
end
|