Jump to content


Photo

Country_select And The Label


  • Please log in to reply
1 reply to this topic

#1 SSteve

SSteve

    New Member

  • Members
  • Pip
  • 1 posts

Posted 19 May 2009 - 07:25 AM

The fourth paragraph on page 137 says "Remember how country_select calls the select method? It now calls the method that provides the label." To which method does that second sentence refer? Removing the "f.label" call from _form.html.erb results in no label on the country field.

#2 simonstl

simonstl

    Active Member

  • O'Reilly Editor
  • PipPip
  • 35 posts

Posted 24 May 2009 - 04:28 AM

QUOTE (SSteve @ May 19 2009, 03:25 PM) <{POST_SNAPBACK}>
The fourth paragraph on page 137 says "Remember how country_select calls the select method? It now calls the method that provides the label." To which method does that second sentence refer? Removing the "f.label" call from _form.html.erb results in no label on the country field.


Sorry for the delay. This proves to have been a really problematic section, a place where I should have shown more of the code from the sample.

I think the missing piece you're seeking is in TidyFormBuilder:

def select(method, choices, options = {}, html_options = {})
label_for(method, options) + super(method, choices, options, html_options)
end

And because country_select calls select, that missing piece will add the label. It looks like I've complicated matters further because this isn't in guestbook008, but turns up in guestbook009, which you can find at http://simonstl.com/rails/ch09.zip.

I'll need to write this up as an erratum. Let me know if you still have problems.

Thanks!





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users