Method: Primer::Forms::ToggleSwitchForm#render_in
- Defined in:
- app/lib/primer/forms/toggle_switch_form.rb
#render_in(view_context, &block) ⇒ Object
Unlike other instances of Base, ToggleSwitchForm defines its own form and is not given a Rails form builder on instantiation. We do this mostly for ergonomic reasons; it’s much less verbose than if you were required to call form_with/form_for, etc. That said, the rest of the forms framework assumes the presence of a builder so we create our own here. A builder cannot be constructed without a corresponding view context, which is why we have to override render_in and can’t create it in the initializer.
72 73 74 75 76 77 78 |
# File 'app/lib/primer/forms/toggle_switch_form.rb', line 72 def render_in(view_context, &block) @builder = Primer::Forms::Builder.new( nil, nil, view_context, {} ) super end |