-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make possible to use the Wrappers API to define attributes for the components #997
Changes from 17 commits
8268412
7a167ca
fa061b6
95da393
dda2006
645988a
6976fba
df47a85
51bdd20
93161d7
d821015
44f22ca
9e3aae1
6186512
ed18620
3992cfc
4a13b2f
135465f
e9384fb
58220b2
15f0101
0fc7ea8
86d0923
724dff5
3d53595
58f14c3
be5badb
2acb2c1
464932c
44a5dba
266ade3
2fa4b7a
f14fed4
bb2fd3b
3f47fd0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module SimpleForm | ||
module Components | ||
module Errors | ||
def error | ||
def error(context=nil) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like spaces here too |
||
error_text if has_errors? | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,26 @@ module LabelInput | |
include SimpleForm::Components::Labels | ||
end | ||
|
||
def label_input | ||
options[:label] == false ? input : (label + input) | ||
def label_input(context=nil) | ||
if options[:label] == false | ||
deprecated_component(:input ,context) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. space |
||
else | ||
deprecated_component(:label, context) + deprecated_component(:input, context) | ||
end | ||
end | ||
|
||
private | ||
|
||
def deprecated_component(namespace ,context) | ||
method = method(namespace) | ||
|
||
if method.arity == 0 | ||
ActiveSupport::Deprecation.warn(SimpleForm::CUSTOM_INPUT_DEPRECATION_WARN % { name: namespace }) | ||
|
||
method.call | ||
else | ||
method.call(context) | ||
end | ||
end | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module SimpleForm | ||
module Helpers | ||
module WrapperOptions | ||
private | ||
|
||
def merge_wrapper_options(options, context) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dunno if we need a module just for this method. Pushing it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is, but I don't see problem to extract to a module. I'm removing because helpers are related to the HTML attributes and this one is not related to any attribute at all. |
||
if context | ||
options.merge(context.options) do |_, oldval, newval| | ||
if Array === oldval | ||
oldval + Array(newval) | ||
end | ||
end | ||
else | ||
options | ||
end | ||
end | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this Pull Request URL on this message could be useful too.