Skip to content

Commit ce729f8

Browse files
committed
Check if ::Components::Base exists and use that; otherwise use ::Phlex::HTML
1 parent 518c791 commit ce729f8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/superform/rails.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
module Superform
44
module Rails
5-
# The `ApplicationComponent` is the superclass for all components in your application.
6-
Component = ::Phlex::HTML
5+
# When this is included in a Rails app, check if `Components::Base` is defined and
6+
# inherit from that so we get all the users stuff; otherwise inherit from Phlex::HTML,
7+
# which means we won't have all the users methods and overrides.
8+
Component = defined?(::Components::Base) ? ::Components::Base : ::Phlex::HTML
79

810
# A Phlex::HTML view module that accepts a model and sets a `Superform::Namespace`
911
# with the `Object#model_name` as the key and maps the object to form fields

0 commit comments

Comments
 (0)