3

Introduce `field_name` view helper by seanpdoyle · Pull Request #43409 · rails/r...

 2 years ago
source link: https://github.com/rails/rails/pull/43409
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

Contributor

seanpdoyle commented on Oct 8

The field_name helper and corresponding FormBuilder#field_name
method provide an Action View-compliant way of overriding a form field
element's [name] attribute (similar to field_id and
FormBuilder#field_id introduced in #40127[][]).

text_field_tag :post, :title, name: field_name(:post, :title, :subtitle)
  # => <input type="text" name="post[title][subtitle]">

text_field_tag :post, :tag, name: field_name(:post, :tag, multiple: true)
  # => <input type="text" name="post[tag][]">

form_for @post do |f|
  f.field_tag :tag, name: f.field_name(:tag, multiple: true)
  # => <input type="text" name="post[tag][]">
end

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK