-
-
Notifications
You must be signed in to change notification settings - Fork 47
Raise when options_for_select
is used as a value
#293
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
base: main
Are you sure you want to change the base?
Conversation
|
||
def select_tag(name, *, **, &block) | ||
output = if block | ||
view_context.select_tag(name, capture(&block), *, **) |
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.
This actually differs form the official API in this case.
@@ -4,5 +4,17 @@ module Phlex::Rails::Helpers::OptionsForSelect | |||
extend Phlex::Rails::HelperMacros | |||
|
|||
# [Rails Docs](https://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-options_for_select) | |||
register_output_helper def options_for_select(...) = nil | |||
def options_for_select(*args, **kwargs, &block) |
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.
Should probably do this for options_from_collection_for_select
too.
class Phlex::Rails::Never < BasicObject | ||
def initialize(&block) | ||
@block = block | ||
end | ||
|
||
def method_missing(method_name, *, **) | ||
@block.call(method_name, *, **) | ||
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.
This is so creative!
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.
You should see the PR I gave up on. It was popping things off the buffer. 🤣
The technique works but I thought it was too much to maintain.
No description provided.