From 5f5496c7f3a9351d3e6caef727654fa2b4bdb311 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sun, 24 Oct 2010 00:35:47 +0200 Subject: switches guides code syntax highlighting to the better SyntaxHighlighter, I did my best with the theme, I swear --- railties/guides/source/form_helpers.textile | 16 +++++++++++----- railties/guides/source/layout.html.erb | 17 ++++++++++++----- 2 files changed, 23 insertions(+), 10 deletions(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/form_helpers.textile b/railties/guides/source/form_helpers.textile index b795d126e6..80e0421b48 100644 --- a/railties/guides/source/form_helpers.textile +++ b/railties/guides/source/form_helpers.textile @@ -59,13 +59,13 @@ To create this form you will use +form_tag+, +label_tag+, +text_field_tag+, and A basic search form - + <%= form_tag(search_path, :method => "get") do %> <%= label_tag(:q, "Search for:") %> <%= text_field_tag(:q) %> <%= submit_tag("Search") %> <% end %> - + TIP: +search_path+ can be a named route specified in "routes.rb" as:
match "search" => "search"This declares for path "/search" to call action "search" from controller "search". @@ -130,14 +130,16 @@ Checkboxes are form controls that give the user a set of options they can enable <%= label_tag(:pet_dog, "I own a dog") %> <%= check_box_tag(:pet_cat) %> <%= label_tag(:pet_cat, "I own a cat") %> + output: + - + The second parameter to +check_box_tag+ is the value of the input. This is the value that will be submitted by the browser if the checkbox is ticked (i.e. the value that will be present in the +params+ hash). With the above form you would check the value of +params[:pet_dog]+ and +params[:pet_cat]+ to see which pets the user owns. @@ -150,14 +152,16 @@ Radio buttons, while similar to checkboxes, are controls that specify a set of o <%= label_tag(:age_child, "I am younger than 21") %> <%= radio_button_tag(:age, "adult") %> <%= label_tag(:age_adult, "I'm over 21") %> + output: + - + As with +check_box_tag+ the second parameter to +radio_button_tag+ is the value of the input. Because these two radio buttons share the same name (age) the user will only be able to select one and +params[:age]+ will contain either "child" or "adult". @@ -171,13 +175,15 @@ Other form controls worth mentioning are the text area, password input and hidde <%= text_area_tag(:message, "Hi, nice site", :size => "24x6") %> <%= password_field_tag(:password) %> <%= hidden_field_tag(:parent_id, "5") %> + output: + - + Hidden inputs are not shown to the user, but they hold data like any textual input. Values inside them can be changed with JavaScript. diff --git a/railties/guides/source/layout.html.erb b/railties/guides/source/layout.html.erb index f0aa227c7e..d4b87dc45b 100644 --- a/railties/guides/source/layout.html.erb +++ b/railties/guides/source/layout.html.erb @@ -8,13 +8,10 @@ <%= yield(:page_title) || 'Ruby on Rails guides' %> - - - - - + + <% if @edge %> @@ -120,5 +117,15 @@

"Rails", "Ruby on Rails", and the Rails logo are trademarks of David Heinemeier Hansson. All rights reserved.

+ + + + + + + + -- cgit v1.2.3