SlideShare una empresa de Scribd logo
1 de 1
Descargar para leer sin conexión
PART ONE

help! it's

FORM HELPERS

a Ruby on Rails
cheat sheet guide
by Amy Hoy

Form helpers make building Rails-friendly forms super easy. Use 'em in views,
including layouts and partials. Save time, save money!

Step 1

Step 2

Form helpers belong to one of three groups:

*
*
*

Form Tag Helpers
create fields not based on your model
create fields based on your model/objects
Form Helpers
Form Options Helpers create select fields (lists, etc.)

Start, submit, and end forms

the controller method to parse the form

<%= start_form_tag :action => 'update', :id => @books %>
For forms that work from an existing object, use :id
to specify the object. When creating new objects,
leave it off.
the button's value
<%= submit_tag "Create" %>
<%= end_form_tag %>

Step 3a

except
date_helper!

the object name

(e.g. appearance)
no args here

Understand the API docs
http://rails.rubyonrails.com/classes/ActionView/Helpers/FormHelper.html
There are just too many form helper methods for me to list 'em all. But for the
form tags based on objects/models, there's a formula to make grokking the API
docs a little easier.
the singular name of the object/controller.
e.g. "book" or "user" or "article"

options as hash parameters.
e.g. "rows" => 50, or "size" => 10

text_area(object, method, options = {})
the column name (really an ActiveRecord method)

Step 3b

Real-world examples of #3
<%= text_field "user","first_name", "size" => 25 %>
<%= password_field "user","password" %>
<%= text_area "book","description", "rows" => 20, "cols" => 90 %>

© 2005 Amy Hoy / amy@infocookie.com / www.slash7.com
License — see http://creativecommons.org/licenses/by-nc-sa/2.0/

Más contenido relacionado

Similar a Ruby on rails cheat sheet form helpers

Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2RORLAB
 
Fraudpointer - Google Apps integration
Fraudpointer  - Google Apps integrationFraudpointer  - Google Apps integration
Fraudpointer - Google Apps integrationFraudpointer.com
 
Front End Frameworks - are they accessible
Front End Frameworks - are they accessibleFront End Frameworks - are they accessible
Front End Frameworks - are they accessibleRuss Weakley
 
Vancouver League of Drupallers - Remembering the User (August 2008)
Vancouver League of Drupallers - Remembering the User (August 2008)Vancouver League of Drupallers - Remembering the User (August 2008)
Vancouver League of Drupallers - Remembering the User (August 2008)baronmunchowsen
 
Understanding form helpers
Understanding form helpersUnderstanding form helpers
Understanding form helpersBruno Almeida
 
Access tips access and sql part 6 dynamic reports
Access tips  access and sql part 6  dynamic reportsAccess tips  access and sql part 6  dynamic reports
Access tips access and sql part 6 dynamic reportsquest2900
 
A deep dive into accessible names
A deep dive into accessible namesA deep dive into accessible names
A deep dive into accessible namesRuss Weakley
 
Model builder in ARC GIS
Model builder in ARC GISModel builder in ARC GIS
Model builder in ARC GISKU Leuven
 
Affiliate Management Platform
Affiliate Management  Platform Affiliate Management  Platform
Affiliate Management Platform Sudhi Ranjan Das
 
Inventory management system
Inventory management systemInventory management system
Inventory management systemALMAHMUD420
 
Autocad excel vba
Autocad excel vbaAutocad excel vba
Autocad excel vbarjg_vijay
 
Custom Forms and Configuration Forms in Drupal 8
Custom Forms and Configuration Forms in Drupal 8Custom Forms and Configuration Forms in Drupal 8
Custom Forms and Configuration Forms in Drupal 8Italo Mairo
 
Drupal 6 FormAPI Presentation
Drupal 6 FormAPI PresentationDrupal 6 FormAPI Presentation
Drupal 6 FormAPI PresentationBoldSource
 
How to Use Material UI Tooltip Component Like a Pro
How to Use Material UI Tooltip Component Like a ProHow to Use Material UI Tooltip Component Like a Pro
How to Use Material UI Tooltip Component Like a ProRonDosh
 
AIA101.3.Access Reports And Forms
AIA101.3.Access Reports And FormsAIA101.3.Access Reports And Forms
AIA101.3.Access Reports And FormsDan D'Urso
 

Similar a Ruby on rails cheat sheet form helpers (20)

Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2
 
Fraudpointer - Google Apps integration
Fraudpointer  - Google Apps integrationFraudpointer  - Google Apps integration
Fraudpointer - Google Apps integration
 
CSS_Forms.pdf
CSS_Forms.pdfCSS_Forms.pdf
CSS_Forms.pdf
 
Front End Frameworks - are they accessible
Front End Frameworks - are they accessibleFront End Frameworks - are they accessible
Front End Frameworks - are they accessible
 
Vancouver League of Drupallers - Remembering the User (August 2008)
Vancouver League of Drupallers - Remembering the User (August 2008)Vancouver League of Drupallers - Remembering the User (August 2008)
Vancouver League of Drupallers - Remembering the User (August 2008)
 
Understanding form helpers
Understanding form helpersUnderstanding form helpers
Understanding form helpers
 
Access tips access and sql part 6 dynamic reports
Access tips  access and sql part 6  dynamic reportsAccess tips  access and sql part 6  dynamic reports
Access tips access and sql part 6 dynamic reports
 
A deep dive into accessible names
A deep dive into accessible namesA deep dive into accessible names
A deep dive into accessible names
 
Lightning Components Workshop
Lightning Components WorkshopLightning Components Workshop
Lightning Components Workshop
 
Access5
Access5Access5
Access5
 
Model builder in ARC GIS
Model builder in ARC GISModel builder in ARC GIS
Model builder in ARC GIS
 
Chapter09
Chapter09Chapter09
Chapter09
 
Affiliate Management Platform
Affiliate Management  Platform Affiliate Management  Platform
Affiliate Management Platform
 
Inventory management system
Inventory management systemInventory management system
Inventory management system
 
Autocad excel vba
Autocad excel vbaAutocad excel vba
Autocad excel vba
 
Custom Forms and Configuration Forms in Drupal 8
Custom Forms and Configuration Forms in Drupal 8Custom Forms and Configuration Forms in Drupal 8
Custom Forms and Configuration Forms in Drupal 8
 
Drupal 6 FormAPI Presentation
Drupal 6 FormAPI PresentationDrupal 6 FormAPI Presentation
Drupal 6 FormAPI Presentation
 
Actionview
ActionviewActionview
Actionview
 
How to Use Material UI Tooltip Component Like a Pro
How to Use Material UI Tooltip Component Like a ProHow to Use Material UI Tooltip Component Like a Pro
How to Use Material UI Tooltip Component Like a Pro
 
AIA101.3.Access Reports And Forms
AIA101.3.Access Reports And FormsAIA101.3.Access Reports And Forms
AIA101.3.Access Reports And Forms
 

Ruby on rails cheat sheet form helpers

  • 1. PART ONE help! it's FORM HELPERS a Ruby on Rails cheat sheet guide by Amy Hoy Form helpers make building Rails-friendly forms super easy. Use 'em in views, including layouts and partials. Save time, save money! Step 1 Step 2 Form helpers belong to one of three groups: * * * Form Tag Helpers create fields not based on your model create fields based on your model/objects Form Helpers Form Options Helpers create select fields (lists, etc.) Start, submit, and end forms the controller method to parse the form <%= start_form_tag :action => 'update', :id => @books %> For forms that work from an existing object, use :id to specify the object. When creating new objects, leave it off. the button's value <%= submit_tag "Create" %> <%= end_form_tag %> Step 3a except date_helper! the object name (e.g. appearance) no args here Understand the API docs http://rails.rubyonrails.com/classes/ActionView/Helpers/FormHelper.html There are just too many form helper methods for me to list 'em all. But for the form tags based on objects/models, there's a formula to make grokking the API docs a little easier. the singular name of the object/controller. e.g. "book" or "user" or "article" options as hash parameters. e.g. "rows" => 50, or "size" => 10 text_area(object, method, options = {}) the column name (really an ActiveRecord method) Step 3b Real-world examples of #3 <%= text_field "user","first_name", "size" => 25 %> <%= password_field "user","password" %> <%= text_area "book","description", "rows" => 20, "cols" => 90 %> © 2005 Amy Hoy / amy@infocookie.com / www.slash7.com License — see http://creativecommons.org/licenses/by-nc-sa/2.0/