Skip to content

Commit 69b6c72

Browse files
committed
Improve docs on the Field class
1 parent bc869e4 commit 69b6c72

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

lib/superform/rails/field.rb

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,41 @@ module Rails
1212
# end
1313
#
1414
# class Field < Field
15-
# def label(**attributes)
16-
# MyLabel.new(self, **attributes)
15+
# def label(**, &)
16+
# MyLabel.new(self, **, &)
17+
# end
18+
#
19+
# def input(class: nil, **)
20+
# super(class: ["input input-outline", grab(class:)])
1721
# end
1822
# end
1923
# end
2024
# ```
21-
##
25+
#
2226
# Now all calls to `label` will have the `text-bold` class applied to it.
2327
class Field < Superform::Field
2428
def button(**attributes)
25-
Components::Button.new(self, attributes:)
29+
Components::Button.new(field, attributes:)
2630
end
2731

2832
def input(**attributes)
29-
Components::Input.new(self, attributes:)
33+
Components::Input.new(field, attributes:)
3034
end
3135

3236
def checkbox(**attributes)
33-
Components::Checkbox.new(self, attributes:)
37+
Components::Checkbox.new(field, attributes:)
3438
end
3539

3640
def label(**attributes, &)
37-
Components::Label.new(self, attributes:, &)
41+
Components::Label.new(field, attributes:, &)
3842
end
3943

4044
def textarea(**attributes)
41-
Components::Textarea.new(self, attributes:)
45+
Components::Textarea.new(field, attributes:)
4246
end
4347

4448
def select(*collection, **attributes, &)
45-
Components::Select.new(self, attributes:, collection:, &)
49+
Components::Select.new(field, attributes:, collection:, &)
4650
end
4751

4852
# HTML5 input type convenience methods - clean API without _field suffix

0 commit comments

Comments
 (0)