O'Reilly Forums: Country_select And The Label - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Country_select And The Label

#1 User is offline   SSteve 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 19-May 09

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.
0

#2 User is offline   simonstl 

  • Active Member
  • PipPip
  • Group: O'Reilly Editor
  • Posts: 35
  • Joined: 17-September 08

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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users