Skip to content

Using the DateField helper in phlex-rails #497

Answered by joeldrapper
wdiechmann asked this question in Help
Discussion options

You must be logged in to vote

I think you could probably do this from the component.

def field_for(*args, **kwargs) # takes a block (we don't need to specify that because we're yielding)
  # save the current value of @form. We'll need it later.
  original_form = @form

  begin
    # delegate the arguments to the fields_for method on the @form
    @form.fields_for(*args, **kwargs) do |f|
      # temporarily set @form to point to the fields_for form builder
      @form = f

      # yield the component while it has @from scoped to the fields_for form builder
      yield(self)
    end
  ensure
    # set the form back to the original form before scoping it
    @form = original_form
  end
end

Replies: 11 comments 16 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@joeldrapper
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
9 replies
@wdiechmann
Comment options

@wdiechmann
Comment options

@wdiechmann
Comment options

@joeldrapper
Comment options

@wdiechmann
Comment options

Comment options

You must be logged in to vote
1 reply
@wdiechmann
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@wdiechmann
Comment options

@joeldrapper
Comment options

@wdiechmann
Comment options

@wdiechmann
Comment options

@joeldrapper
Comment options

Answer selected by wdiechmann
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants