Hello all,

I'm getting this weird '<input name value='2' type='hidden' />' text
printed out in my form. See attached image. I've spent too much time
trying to figure it out already and it's not going to stop me from
moving on for now.

As you can see it's still very early on.

I'm using nested_attributes_for and fields_for: (also HAML)
=============================================================

= form_for @user, :url => {:action => 'update'} do |f|
# removed fields here
= f.fields_for :roles do |r|
- unless r.object.for_object.nil?
= r.label :role, r.object.for_object.name
= r.select :role, Role::Roles.options_for_select
= f.submit "Update User"

=============================================================

Any thoughts would be appreciated. Thank you

Attachments:
http://www.ruby-forum.com/attachment/6926/nested_fields_issue.jpg


--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Colin Law at Jan 20, 2012 at 2:10 pm

    On 20 January 2012 14:01, Keith Raymond wrote:
    Hello all,

    I'm getting this weird '<input name value='2' type='hidden' />' text
    printed out in my form.  See attached image.  I've spent too much time
    trying to figure it out already and it's not going to stop me from
    moving on for now.

    As you can see it's still very early on.

    I'm using nested_attributes_for and fields_for: (also HAML)
    =============================================================

    = form_for @user, :url => {:action => 'update'} do |f|
    # removed fields here
    = f.fields_for :roles do |r|
    - unless r.object.for_object.nil?
    = r.label :role, r.object.for_object.name
    = r.select :role, Role::Roles.options_for_select
    = f.submit "Update User"

    =============================================================

    Any thoughts would be appreciated.  Thank you
    That sort of thing is often caused by invalid html.
    Try copying the full page source (probably right click View Source in
    the browser) and pasting it into the w3c html validator.

    Colin

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Bala TS at Jan 21, 2012 at 3:46 am
    Hai!

    # you can try this way:

    <%= form_for :module_name do |form| %>

    <%= form.hidden_field :name,:value=>'2'%>

    <%end%>

    # controller side you can get like this way

    params[:user]

    Bye:)
    bdeveloper01

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Ian Smith at May 22, 2012 at 7:34 pm
    Hey, this should do the trick:

    = form_for @user, :url => {:action => 'update'} do |f|
    = f.fields_for :roles do |r|
    - if r.object.for_object.present?
    = r.label :role, r.object.for_object.name
    = r.select :role, Role::Roles.options_for_select
    - else
    =""
    = f.submit "Update User"

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJan 20, '12 at 2:02p
activeMay 22, '12 at 7:34p
posts4
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Ian Smith: 3 posts Colin Law: 1 post

People

Translate

site design / logo © 2021 Grokbase