SlideShare ist ein Scribd-Unternehmen logo
1 von 1
Downloaden Sie, um offline zu lesen
PART ONE
help! it's                                                                             a Ruby on Rails

                   FORM HELPERS                                                        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!


               Form helpers belong to one of three groups:
Step 1
               *   Form Tag Helpers    create fields not based on your model                      except
               *                    create fields based on your model/objects
                   Form Helpers                                                                date_helper!
                   Form Options Helpers create select fields (lists, etc.)
               *
                                                                     the controller method to parse the form
              Start, submit, and end forms
Step 2        <%= 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,                              the object name
                                  leave it off.           the button's value
                                                              (e.g. appearance)
              <%= submit_tag quot;Createquot; %>
              <%= end_form_tag %>                            no args here


              Understand the API docs
 Step 3a       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.       options as hash parameters.
                     e.g. quot;bookquot; or quot;userquot; or quot;articlequot;       e.g. quot;rowsquot; => 50, or quot;sizequot; => 10

               text_area(object, method, options = {})

                       the column name (really an ActiveRecord method)



               Real-world examples of #3
 Step 3b
              <%= text_field quot;userquot;,quot;first_namequot;, quot;sizequot; => 25 %>
              <%= password_field quot;userquot;,quot;passwordquot; %>
             <%= text_area quot;bookquot;,quot;descriptionquot;, quot;rowsquot; => 20, quot;colsquot; => 90 %>



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

Weitere ähnliche Inhalte

Andere mochten auch

M2 Special Thanks To Artist
M2 Special Thanks To ArtistM2 Special Thanks To Artist
M2 Special Thanks To ArtistFuture News
 
Alcoholismo
AlcoholismoAlcoholismo
Alcoholismojoanlo22
 
Iran 1357. Posters from the revolution
Iran 1357. Posters from the revolutionIran 1357. Posters from the revolution
Iran 1357. Posters from the revolutionibexbox
 
Analysis of horror opening new
Analysis of horror opening newAnalysis of horror opening new
Analysis of horror opening newtaylorcockley
 
Electronic portfolio
Electronic portfolio Electronic portfolio
Electronic portfolio taylorcockley
 
Electronic portfolio- Top 20
Electronic portfolio- Top 20Electronic portfolio- Top 20
Electronic portfolio- Top 20taylorcockley
 
Mobile Monday Peer Awards - Xumii
Mobile Monday Peer Awards -  XumiiMobile Monday Peer Awards -  Xumii
Mobile Monday Peer Awards - Xumiixumii
 
Electronic portfolio - Top 40
Electronic portfolio - Top 40Electronic portfolio - Top 40
Electronic portfolio - Top 40taylorcockley
 
M4 Artists Thanks
M4 Artists ThanksM4 Artists Thanks
M4 Artists ThanksFuture News
 
Frederick Lipp Visits GESS
Frederick Lipp Visits GESSFrederick Lipp Visits GESS
Frederick Lipp Visits GESSranitasmart
 

Andere mochten auch (17)

M2 Special Thanks To Artist
M2 Special Thanks To ArtistM2 Special Thanks To Artist
M2 Special Thanks To Artist
 
2.1.2wire-wound
2.1.2wire-wound2.1.2wire-wound
2.1.2wire-wound
 
Alcoholismo
AlcoholismoAlcoholismo
Alcoholismo
 
Iran 1357. Posters from the revolution
Iran 1357. Posters from the revolutionIran 1357. Posters from the revolution
Iran 1357. Posters from the revolution
 
Analysis of horror opening new
Analysis of horror opening newAnalysis of horror opening new
Analysis of horror opening new
 
Electronic portfolio
Electronic portfolio Electronic portfolio
Electronic portfolio
 
Para Ti
Para TiPara Ti
Para Ti
 
Film institutions
Film institutionsFilm institutions
Film institutions
 
Electronic portfolio- Top 20
Electronic portfolio- Top 20Electronic portfolio- Top 20
Electronic portfolio- Top 20
 
Mobile Monday Peer Awards - Xumii
Mobile Monday Peer Awards -  XumiiMobile Monday Peer Awards -  Xumii
Mobile Monday Peer Awards - Xumii
 
Proyecto 802
Proyecto 802Proyecto 802
Proyecto 802
 
Pph23
Pph23Pph23
Pph23
 
Magazine conventions
Magazine conventionsMagazine conventions
Magazine conventions
 
Electronic portfolio - Top 40
Electronic portfolio - Top 40Electronic portfolio - Top 40
Electronic portfolio - Top 40
 
Brief Synopsis
Brief Synopsis Brief Synopsis
Brief Synopsis
 
M4 Artists Thanks
M4 Artists ThanksM4 Artists Thanks
M4 Artists Thanks
 
Frederick Lipp Visits GESS
Frederick Lipp Visits GESSFrederick Lipp Visits GESS
Frederick Lipp Visits GESS
 

Ähnlich wie Form Helpers

Ruby on rails cheat sheet form helpers
Ruby on rails cheat sheet   form helpersRuby on rails cheat sheet   form helpers
Ruby on rails cheat sheet form helpersTharcius Silva
 
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
 
Boston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsBoston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsJohn Brunswick
 
Jasig Rubyon Rails
Jasig Rubyon RailsJasig Rubyon Rails
Jasig Rubyon RailsPaul Pajo
 
Intro to Rails ActiveRecord
Intro to Rails ActiveRecordIntro to Rails ActiveRecord
Intro to Rails ActiveRecordMark Menard
 
Getting started with Rails (4), Season 2
Getting started with Rails (4), Season 2Getting started with Rails (4), Season 2
Getting started with Rails (4), Season 2RORLAB
 
Advisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptAdvisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptdominion
 
RoR 101: Session 2
RoR 101: Session 2RoR 101: Session 2
RoR 101: Session 2Rory Gianni
 
Widgets: Making Your Site Great and Letting Others Help - WordCamp Victoria
Widgets: Making Your Site Great and Letting Others Help - WordCamp VictoriaWidgets: Making Your Site Great and Letting Others Help - WordCamp Victoria
Widgets: Making Your Site Great and Letting Others Help - WordCamp VictoriaJeff Richards
 
Ruby On Rails Tutorial
Ruby On Rails TutorialRuby On Rails Tutorial
Ruby On Rails Tutorialsunniboy
 
Component and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHPComponent and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHPStephan Schmidt
 
merb.intro
merb.intromerb.intro
merb.intropjb3
 
WordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big wordsWordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big wordsTomAuger
 
Agile Development With Hobo
Agile Development With HoboAgile Development With Hobo
Agile Development With HoboEvarist Lobo
 
Getting started with Rails (3), Season 2
Getting started with Rails (3), Season 2Getting started with Rails (3), Season 2
Getting started with Rails (3), Season 2RORLAB
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On RailsWen-Tien Chang
 
Form design - challenges and solutions
Form design - challenges and solutionsForm design - challenges and solutions
Form design - challenges and solutionsfnkdumplin
 

Ähnlich wie Form Helpers (20)

Ruby on rails cheat sheet form helpers
Ruby on rails cheat sheet   form helpersRuby on rails cheat sheet   form helpers
Ruby on rails cheat sheet form helpers
 
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)
 
Boston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsBoston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on Rails
 
Jasig Rubyon Rails
Jasig Rubyon RailsJasig Rubyon Rails
Jasig Rubyon Rails
 
Intro to Rails ActiveRecord
Intro to Rails ActiveRecordIntro to Rails ActiveRecord
Intro to Rails ActiveRecord
 
CRUD with Dojo
CRUD with DojoCRUD with Dojo
CRUD with Dojo
 
Getting started with Rails (4), Season 2
Getting started with Rails (4), Season 2Getting started with Rails (4), Season 2
Getting started with Rails (4), Season 2
 
Advisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptAdvisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScript
 
RoR 101: Session 2
RoR 101: Session 2RoR 101: Session 2
RoR 101: Session 2
 
Widgets: Making Your Site Great and Letting Others Help - WordCamp Victoria
Widgets: Making Your Site Great and Letting Others Help - WordCamp VictoriaWidgets: Making Your Site Great and Letting Others Help - WordCamp Victoria
Widgets: Making Your Site Great and Letting Others Help - WordCamp Victoria
 
Ruby On Rails Tutorial
Ruby On Rails TutorialRuby On Rails Tutorial
Ruby On Rails Tutorial
 
Fapi
FapiFapi
Fapi
 
Component and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHPComponent and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHP
 
merb.intro
merb.intromerb.intro
merb.intro
 
WordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big wordsWordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big words
 
Agile Development With Hobo
Agile Development With HoboAgile Development With Hobo
Agile Development With Hobo
 
Getting started with Rails (3), Season 2
Getting started with Rails (3), Season 2Getting started with Rails (3), Season 2
Getting started with Rails (3), Season 2
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On Rails
 
Form helpers
Form helpersForm helpers
Form helpers
 
Form design - challenges and solutions
Form design - challenges and solutionsForm design - challenges and solutions
Form design - challenges and solutions
 

Kürzlich hochgeladen

Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 

Kürzlich hochgeladen (20)

Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 

Form Helpers

  • 1. PART ONE help! it's a Ruby on Rails FORM HELPERS 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! Form helpers belong to one of three groups: Step 1 * Form Tag Helpers create fields not based on your model except * create fields based on your model/objects Form Helpers date_helper! Form Options Helpers create select fields (lists, etc.) * the controller method to parse the form Start, submit, and end forms Step 2 <%= 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, the object name leave it off. the button's value (e.g. appearance) <%= submit_tag quot;Createquot; %> <%= end_form_tag %> no args here Understand the API docs Step 3a 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. options as hash parameters. e.g. quot;bookquot; or quot;userquot; or quot;articlequot; e.g. quot;rowsquot; => 50, or quot;sizequot; => 10 text_area(object, method, options = {}) the column name (really an ActiveRecord method) Real-world examples of #3 Step 3b <%= text_field quot;userquot;,quot;first_namequot;, quot;sizequot; => 25 %> <%= password_field quot;userquot;,quot;passwordquot; %> <%= text_area quot;bookquot;,quot;descriptionquot;, quot;rowsquot; => 20, quot;colsquot; => 90 %> © 2005 Amy Hoy / amy@infocookie.com / www.slash7.com License — see http://creativecommons.org/licenses/by-nc-sa/2.0/