Skip to content

using hidden_field #502

Answered by joeldrapper
wdiechmann asked this question in Help
Discussion options

You must be logged in to vote

The HiddenField adapter corresponds to this view helper https://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-hidden_field_tag

You should never need to use that adapter because it's better to work with the yielded form builder from the form_with or form_for adapters.

The FormWith adapter yields an adapted Rails FormBuilder that corresponds to this https://api.rubyonrails.org/classes/ActionView/Helpers/FormBuilder.html

That means you can call methods on the yielded form builder like this:

class Foo < Phlex::HTML
  include Phlex::Rails::Hepers::FormWith

  def template
    form_with(model: Post.new) do |f|
      f.hidden_field :bar
    end
  end
end

This is the …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
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
Converted from issue

This discussion was converted from issue #500 on February 27, 2023 11:04.