SlideShare a Scribd company logo
Forms in Drupal

     Oleksandr Masovets
    E-mail: krasnyj@neformat.com.ua
                  Skype: krasnyjdirex
Gold Sponsor of
DrupalCamp Kyiv 2011
Silver Sponsors of
DrupalCamp Kyiv 2011
Working with forms
• Form
    – Render
    – System form
•   Form alter
•   Form validation
•   Form submit
•   Destination (redirect)
Form
Form call function: drupal_get_form($form_id);
•$form_id - the unique string identifying the desired form. If a
function with that name exists, it is called to build the form array.

drupal_get_form() does the following:
•Starts the entire form-building process by getting the $form from
the builder function.
•Translates the $form['name'] items into actual form elements.
•Performs any validation and "clean-up" that needs to be done, and
calls custom validation functions if declared.
•Submits the form if a submit function is declared, and the form has
been submitted.
•Calls any custom theming functions that have been declared.
•Returns an HTML string which contains the actual form.
Form elements
Form element structure
Required parameters:
$form[‘element name’] = array (
   ‘#type’ = ‘element type’,
);

Every element automatically has these default values:
•#description = NULL
•#attributes = array()
•#required = FALSE
•#tree = FALSE
•#parents = array()
AhahAjax callback for an
            element
• Using ‘#ahah’(D6) or ‘#ajax’(D7)
  attributes to builds a form element with
  a set of #ahah#ajax properties.
• Using ‘#ajax[‘callback’]’(D7) or
  ‘#ahah[‘path’]’(D6)#ajax[‘path’]’(D7) to
  locate ajax function.
• Using additional ahahajax options to
  change behavior of the form element.
Theming forms
• Adding '#theme' attributes to the form
  and/or elements.
• Including any markup directly as an
  element in the $form array.
• Break out any markup into a separate
  theme function.
Form alter
Perform alterations before a form is rendered:

hook_form_alter(&$form, &$form_state, $form_id);
                      OR
hook_form_FORM_ID_alter(&$form, &$form_state);
Form validation
• Adding ‘#validate’ attribute (an array with list of
  custom validation functions) to the form.
• Adding  ‘#element_validate’ attributes (an array with
  list of custom validation functions) to the form
  elements.
• Using myform_validation($form, &$form_state)
  function.
• The validation functions must use form_error()
  or form_set_error() functions to flag the element as
  having an error if the validation fails.
Form submit and redirect
• Adding ‘#submit’ attribute (an array with list of custom
  submit functions) to the form.
• Using myform_submit($form, &$form_state) function.
• To determine where the user should be sent after the form
  is processed, the _submit function can place a path or URL
  in $form_state['redirect'] which will be the target of a
  drupal_goto.
• Every form is redirected after a submit. If nothing stored
  in $form_state['redirect'], the form will simply be redirected
  to itself after a submit.
Links
• http://api.drupal.org
• http://api.drupal.org/api/drupal/develope
  r--topics--forms_api_reference.html/
• http://drupal.org/node/751826
Forms in Drupal

     Oleksandr Masovets
    E-mail: krasnyj@neformat.com.ua
                  Skype: krasnyjdirex

More Related Content

What's hot

Autoforms
AutoformsAutoforms
Autoforms
jeff kit
 
Template rendering in rails
Template rendering in rails Template rendering in rails
Template rendering in rails
Hung Wu Lo
 
Rugalytics | Ruby Manor Nov 2008
Rugalytics | Ruby Manor Nov 2008Rugalytics | Ruby Manor Nov 2008
Rugalytics | Ruby Manor Nov 2008
Rob
 
Creating Multi-Page Data Entry Controllers
Creating Multi-Page Data Entry ControllersCreating Multi-Page Data Entry Controllers
Creating Multi-Page Data Entry Controllers
Salesforce Developers
 
Curso Symfony - Clase 3
Curso Symfony - Clase 3Curso Symfony - Clase 3
Curso Symfony - Clase 3
Javier Eguiluz
 
Taking Apex and Visualforce Above and Beyond
Taking Apex and Visualforce Above and BeyondTaking Apex and Visualforce Above and Beyond
Taking Apex and Visualforce Above and Beyond
Salesforce Developers
 
Composed of
Composed ofComposed of
Composed of
testflyjets
 

What's hot (9)

Autoforms
AutoformsAutoforms
Autoforms
 
Template rendering in rails
Template rendering in rails Template rendering in rails
Template rendering in rails
 
java ee 6 Petcatalog
java ee 6 Petcatalogjava ee 6 Petcatalog
java ee 6 Petcatalog
 
Exercise in alv
Exercise in alvExercise in alv
Exercise in alv
 
Rugalytics | Ruby Manor Nov 2008
Rugalytics | Ruby Manor Nov 2008Rugalytics | Ruby Manor Nov 2008
Rugalytics | Ruby Manor Nov 2008
 
Creating Multi-Page Data Entry Controllers
Creating Multi-Page Data Entry ControllersCreating Multi-Page Data Entry Controllers
Creating Multi-Page Data Entry Controllers
 
Curso Symfony - Clase 3
Curso Symfony - Clase 3Curso Symfony - Clase 3
Curso Symfony - Clase 3
 
Taking Apex and Visualforce Above and Beyond
Taking Apex and Visualforce Above and BeyondTaking Apex and Visualforce Above and Beyond
Taking Apex and Visualforce Above and Beyond
 
Composed of
Composed ofComposed of
Composed of
 

Viewers also liked

Amarni pitching ideas
Amarni pitching ideasAmarni pitching ideas
Amarni pitching ideasMarni Starr
 
Cross media study trey
Cross media study  treyCross media study  trey
Cross media study treyMarni Starr
 
Gmunden2015cognitivefinal 150602130608-lva1-app6891
Gmunden2015cognitivefinal 150602130608-lva1-app6891Gmunden2015cognitivefinal 150602130608-lva1-app6891
Gmunden2015cognitivefinal 150602130608-lva1-app6891
Sylvain Senecal
 
Varnish and Drupal.
Varnish and Drupal.Varnish and Drupal.
Varnish and Drupal.
Vlad Savitsky
 
Looking for Vulnerable Code. Vlad Savitsky
Looking for Vulnerable Code. Vlad SavitskyLooking for Vulnerable Code. Vlad Savitsky
Looking for Vulnerable Code. Vlad Savitsky
Vlad Savitsky
 
Art of Estimation. Vlad Savitsky
Art of Estimation. Vlad SavitskyArt of Estimation. Vlad Savitsky
Art of Estimation. Vlad Savitsky
Vlad Savitsky
 
Task One: Institutional Research
Task One: Institutional ResearchTask One: Institutional Research
Task One: Institutional ResearchMarni Starr
 

Viewers also liked (8)

Amarni pitching ideas
Amarni pitching ideasAmarni pitching ideas
Amarni pitching ideas
 
Cross media study trey
Cross media study  treyCross media study  trey
Cross media study trey
 
Gmunden2015cognitivefinal 150602130608-lva1-app6891
Gmunden2015cognitivefinal 150602130608-lva1-app6891Gmunden2015cognitivefinal 150602130608-lva1-app6891
Gmunden2015cognitivefinal 150602130608-lva1-app6891
 
Chapter18
Chapter18Chapter18
Chapter18
 
Varnish and Drupal.
Varnish and Drupal.Varnish and Drupal.
Varnish and Drupal.
 
Looking for Vulnerable Code. Vlad Savitsky
Looking for Vulnerable Code. Vlad SavitskyLooking for Vulnerable Code. Vlad Savitsky
Looking for Vulnerable Code. Vlad Savitsky
 
Art of Estimation. Vlad Savitsky
Art of Estimation. Vlad SavitskyArt of Estimation. Vlad Savitsky
Art of Estimation. Vlad Savitsky
 
Task One: Institutional Research
Task One: Institutional ResearchTask One: Institutional Research
Task One: Institutional Research
 

Similar to Oleksandr Masovets. Forms in Drupal. Drupal Camp Kyiv 2011

Fapi
FapiFapi
Learning the basics of the Drupal API
Learning the basics of the Drupal APILearning the basics of the Drupal API
Learning the basics of the Drupal API
Alexandru Badiu
 
Rapid Prototyping with PEAR
Rapid Prototyping with PEARRapid Prototyping with PEAR
Rapid Prototyping with PEAR
Markus Wolff
 
Prateek dayal backbonerails-110528024926-phpapp02
Prateek dayal backbonerails-110528024926-phpapp02Prateek dayal backbonerails-110528024926-phpapp02
Prateek dayal backbonerails-110528024926-phpapp02
Revath S Kumar
 
Single Page Web Apps with Backbone.js and Rails
Single Page Web Apps with Backbone.js and RailsSingle Page Web Apps with Backbone.js and Rails
Single Page Web Apps with Backbone.js and Rails
Prateek Dayal
 
PHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4DevelopersPHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4Developers
Kacper Gunia
 
实战Ecos
实战Ecos实战Ecos
实战Ecos
wanglei999
 
Using the Features API
Using the Features APIUsing the Features API
Using the Features API
cgmonroe
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
Nick Lee
 
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and SimpleDrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
Alexander Varwijk
 
You're Doing it Wrong - WordCamp Atlanta
You're Doing it Wrong - WordCamp AtlantaYou're Doing it Wrong - WordCamp Atlanta
You're Doing it Wrong - WordCamp Atlanta
Chris Scott
 
Dutch PHP Conference - PHPSpec 2 - The only Design Tool you need
Dutch PHP Conference - PHPSpec 2 - The only Design Tool you needDutch PHP Conference - PHPSpec 2 - The only Design Tool you need
Dutch PHP Conference - PHPSpec 2 - The only Design Tool you need
Kacper Gunia
 
Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with example
Katy Slemon
 
Fields in Core: How to create a custom field
Fields in Core: How to create a custom fieldFields in Core: How to create a custom field
Fields in Core: How to create a custom field
Ivan Zugec
 
Implementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord modelsImplementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord models
Kostyantyn Stepanyuk
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Fabien Potencier
 
Rails <form> Chronicle
Rails <form> ChronicleRails <form> Chronicle
Rails <form> Chronicle
Kyosuke MOROHASHI
 
Breaking the limits_of_page_objects
Breaking the limits_of_page_objectsBreaking the limits_of_page_objects
Breaking the limits_of_page_objects
Robert Bossek
 
Symfony CoP: Form component
Symfony CoP: Form componentSymfony CoP: Form component
Symfony CoP: Form component
Samuel ROZE
 

Similar to Oleksandr Masovets. Forms in Drupal. Drupal Camp Kyiv 2011 (20)

Fapi
FapiFapi
Fapi
 
Learning the basics of the Drupal API
Learning the basics of the Drupal APILearning the basics of the Drupal API
Learning the basics of the Drupal API
 
Rapid Prototyping with PEAR
Rapid Prototyping with PEARRapid Prototyping with PEAR
Rapid Prototyping with PEAR
 
Prateek dayal backbonerails-110528024926-phpapp02
Prateek dayal backbonerails-110528024926-phpapp02Prateek dayal backbonerails-110528024926-phpapp02
Prateek dayal backbonerails-110528024926-phpapp02
 
Single Page Web Apps with Backbone.js and Rails
Single Page Web Apps with Backbone.js and RailsSingle Page Web Apps with Backbone.js and Rails
Single Page Web Apps with Backbone.js and Rails
 
PHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4DevelopersPHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4Developers
 
实战Ecos
实战Ecos实战Ecos
实战Ecos
 
Using the Features API
Using the Features APIUsing the Features API
Using the Features API
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
 
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and SimpleDrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
 
You're Doing it Wrong - WordCamp Atlanta
You're Doing it Wrong - WordCamp AtlantaYou're Doing it Wrong - WordCamp Atlanta
You're Doing it Wrong - WordCamp Atlanta
 
Dutch PHP Conference - PHPSpec 2 - The only Design Tool you need
Dutch PHP Conference - PHPSpec 2 - The only Design Tool you needDutch PHP Conference - PHPSpec 2 - The only Design Tool you need
Dutch PHP Conference - PHPSpec 2 - The only Design Tool you need
 
Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with example
 
Fields in Core: How to create a custom field
Fields in Core: How to create a custom fieldFields in Core: How to create a custom field
Fields in Core: How to create a custom field
 
Implementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord modelsImplementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord models
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)
 
Rails <form> Chronicle
Rails <form> ChronicleRails <form> Chronicle
Rails <form> Chronicle
 
Spring batch
Spring batchSpring batch
Spring batch
 
Breaking the limits_of_page_objects
Breaking the limits_of_page_objectsBreaking the limits_of_page_objects
Breaking the limits_of_page_objects
 
Symfony CoP: Form component
Symfony CoP: Form componentSymfony CoP: Form component
Symfony CoP: Form component
 

More from Vlad Savitsky

Css Intro. Vlad Savitsky
Css Intro. Vlad SavitskyCss Intro. Vlad Savitsky
Css Intro. Vlad Savitsky
Vlad Savitsky
 
HTML. Быстрое погружение. Влад Савицкий
HTML. Быстрое погружение. Влад СавицкийHTML. Быстрое погружение. Влад Савицкий
HTML. Быстрое погружение. Влад Савицкий
Vlad Savitsky
 
How to be a believer online. Vlad Savitsky. Novomedia forum 2011
How to be a believer online. Vlad Savitsky. Novomedia forum 2011How to be a believer online. Vlad Savitsky. Novomedia forum 2011
How to be a believer online. Vlad Savitsky. Novomedia forum 2011
Vlad Savitsky
 
Vlad savitsky. Church Site in 15 minutes
Vlad savitsky. Church Site in 15 minutesVlad savitsky. Church Site in 15 minutes
Vlad savitsky. Church Site in 15 minutes
Vlad Savitsky
 
Dmitry Drozdik. how to make friendship between drupal and content manager. dr...
Dmitry Drozdik. how to make friendship between drupal and content manager. dr...Dmitry Drozdik. how to make friendship between drupal and content manager. dr...
Dmitry Drozdik. how to make friendship between drupal and content manager. dr...
Vlad Savitsky
 
Alexey Kostin. Increase site ctr in serp using google rich snippets. DrupalCa...
Alexey Kostin. Increase site ctr in serp using google rich snippets. DrupalCa...Alexey Kostin. Increase site ctr in serp using google rich snippets. DrupalCa...
Alexey Kostin. Increase site ctr in serp using google rich snippets. DrupalCa...
Vlad Savitsky
 
Oleg Natalushko. Drupal server anatomy. DrupalCamp Kyiv 2011
Oleg Natalushko. Drupal server anatomy. DrupalCamp Kyiv 2011Oleg Natalushko. Drupal server anatomy. DrupalCamp Kyiv 2011
Oleg Natalushko. Drupal server anatomy. DrupalCamp Kyiv 2011
Vlad Savitsky
 
Dennis popov. scrum for drupal. drupal camp kyiv 2011
Dennis popov. scrum for drupal. drupal camp kyiv 2011Dennis popov. scrum for drupal. drupal camp kyiv 2011
Dennis popov. scrum for drupal. drupal camp kyiv 2011Vlad Savitsky
 
Andriy Kushnarov. BOND: a giant drupal in a huge company. DrupalCamp Kyiv 2011
Andriy Kushnarov. BOND: a giant drupal in a huge company. DrupalCamp Kyiv 2011Andriy Kushnarov. BOND: a giant drupal in a huge company. DrupalCamp Kyiv 2011
Andriy Kushnarov. BOND: a giant drupal in a huge company. DrupalCamp Kyiv 2011
Vlad Savitsky
 
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
Vlad Savitsky
 
Danilenko Alexander. Drupal 7 theming on Omega. DrupalCamp Kyiv 2011
Danilenko Alexander. Drupal 7 theming on Omega. DrupalCamp Kyiv 2011Danilenko Alexander. Drupal 7 theming on Omega. DrupalCamp Kyiv 2011
Danilenko Alexander. Drupal 7 theming on Omega. DrupalCamp Kyiv 2011
Vlad Savitsky
 
Evgeniy Karelin. Mongo DB integration example solving performance and high lo...
Evgeniy Karelin. Mongo DB integration example solving performance and high lo...Evgeniy Karelin. Mongo DB integration example solving performance and high lo...
Evgeniy Karelin. Mongo DB integration example solving performance and high lo...
Vlad Savitsky
 
Yuriy Gerasimov. Drupal Services. Integration with third party applications. ...
Yuriy Gerasimov. Drupal Services. Integration with third party applications. ...Yuriy Gerasimov. Drupal Services. Integration with third party applications. ...
Yuriy Gerasimov. Drupal Services. Integration with third party applications. ...
Vlad Savitsky
 
Оптимизация JavaScript в Drupal
Оптимизация JavaScript в DrupalОптимизация JavaScript в Drupal
Оптимизация JavaScript в Drupal
Vlad Savitsky
 

More from Vlad Savitsky (14)

Css Intro. Vlad Savitsky
Css Intro. Vlad SavitskyCss Intro. Vlad Savitsky
Css Intro. Vlad Savitsky
 
HTML. Быстрое погружение. Влад Савицкий
HTML. Быстрое погружение. Влад СавицкийHTML. Быстрое погружение. Влад Савицкий
HTML. Быстрое погружение. Влад Савицкий
 
How to be a believer online. Vlad Savitsky. Novomedia forum 2011
How to be a believer online. Vlad Savitsky. Novomedia forum 2011How to be a believer online. Vlad Savitsky. Novomedia forum 2011
How to be a believer online. Vlad Savitsky. Novomedia forum 2011
 
Vlad savitsky. Church Site in 15 minutes
Vlad savitsky. Church Site in 15 minutesVlad savitsky. Church Site in 15 minutes
Vlad savitsky. Church Site in 15 minutes
 
Dmitry Drozdik. how to make friendship between drupal and content manager. dr...
Dmitry Drozdik. how to make friendship between drupal and content manager. dr...Dmitry Drozdik. how to make friendship between drupal and content manager. dr...
Dmitry Drozdik. how to make friendship between drupal and content manager. dr...
 
Alexey Kostin. Increase site ctr in serp using google rich snippets. DrupalCa...
Alexey Kostin. Increase site ctr in serp using google rich snippets. DrupalCa...Alexey Kostin. Increase site ctr in serp using google rich snippets. DrupalCa...
Alexey Kostin. Increase site ctr in serp using google rich snippets. DrupalCa...
 
Oleg Natalushko. Drupal server anatomy. DrupalCamp Kyiv 2011
Oleg Natalushko. Drupal server anatomy. DrupalCamp Kyiv 2011Oleg Natalushko. Drupal server anatomy. DrupalCamp Kyiv 2011
Oleg Natalushko. Drupal server anatomy. DrupalCamp Kyiv 2011
 
Dennis popov. scrum for drupal. drupal camp kyiv 2011
Dennis popov. scrum for drupal. drupal camp kyiv 2011Dennis popov. scrum for drupal. drupal camp kyiv 2011
Dennis popov. scrum for drupal. drupal camp kyiv 2011
 
Andriy Kushnarov. BOND: a giant drupal in a huge company. DrupalCamp Kyiv 2011
Andriy Kushnarov. BOND: a giant drupal in a huge company. DrupalCamp Kyiv 2011Andriy Kushnarov. BOND: a giant drupal in a huge company. DrupalCamp Kyiv 2011
Andriy Kushnarov. BOND: a giant drupal in a huge company. DrupalCamp Kyiv 2011
 
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
 
Danilenko Alexander. Drupal 7 theming on Omega. DrupalCamp Kyiv 2011
Danilenko Alexander. Drupal 7 theming on Omega. DrupalCamp Kyiv 2011Danilenko Alexander. Drupal 7 theming on Omega. DrupalCamp Kyiv 2011
Danilenko Alexander. Drupal 7 theming on Omega. DrupalCamp Kyiv 2011
 
Evgeniy Karelin. Mongo DB integration example solving performance and high lo...
Evgeniy Karelin. Mongo DB integration example solving performance and high lo...Evgeniy Karelin. Mongo DB integration example solving performance and high lo...
Evgeniy Karelin. Mongo DB integration example solving performance and high lo...
 
Yuriy Gerasimov. Drupal Services. Integration with third party applications. ...
Yuriy Gerasimov. Drupal Services. Integration with third party applications. ...Yuriy Gerasimov. Drupal Services. Integration with third party applications. ...
Yuriy Gerasimov. Drupal Services. Integration with third party applications. ...
 
Оптимизация JavaScript в Drupal
Оптимизация JavaScript в DrupalОптимизация JavaScript в Drupal
Оптимизация JavaScript в Drupal
 

Recently uploaded

Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 

Recently uploaded (20)

Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 

Oleksandr Masovets. Forms in Drupal. Drupal Camp Kyiv 2011

  • 1. Forms in Drupal Oleksandr Masovets E-mail: krasnyj@neformat.com.ua Skype: krasnyjdirex
  • 4. Working with forms • Form – Render – System form • Form alter • Form validation • Form submit • Destination (redirect)
  • 5. Form Form call function: drupal_get_form($form_id); •$form_id - the unique string identifying the desired form. If a function with that name exists, it is called to build the form array. drupal_get_form() does the following: •Starts the entire form-building process by getting the $form from the builder function. •Translates the $form['name'] items into actual form elements. •Performs any validation and "clean-up" that needs to be done, and calls custom validation functions if declared. •Submits the form if a submit function is declared, and the form has been submitted. •Calls any custom theming functions that have been declared. •Returns an HTML string which contains the actual form.
  • 7. Form element structure Required parameters: $form[‘element name’] = array ( ‘#type’ = ‘element type’, ); Every element automatically has these default values: •#description = NULL •#attributes = array() •#required = FALSE •#tree = FALSE •#parents = array()
  • 8. AhahAjax callback for an element • Using ‘#ahah’(D6) or ‘#ajax’(D7) attributes to builds a form element with a set of #ahah#ajax properties. • Using ‘#ajax[‘callback’]’(D7) or ‘#ahah[‘path’]’(D6)#ajax[‘path’]’(D7) to locate ajax function. • Using additional ahahajax options to change behavior of the form element.
  • 9. Theming forms • Adding '#theme' attributes to the form and/or elements. • Including any markup directly as an element in the $form array. • Break out any markup into a separate theme function.
  • 10. Form alter Perform alterations before a form is rendered: hook_form_alter(&$form, &$form_state, $form_id); OR hook_form_FORM_ID_alter(&$form, &$form_state);
  • 11. Form validation • Adding ‘#validate’ attribute (an array with list of custom validation functions) to the form. • Adding  ‘#element_validate’ attributes (an array with list of custom validation functions) to the form elements. • Using myform_validation($form, &$form_state) function. • The validation functions must use form_error() or form_set_error() functions to flag the element as having an error if the validation fails.
  • 12. Form submit and redirect • Adding ‘#submit’ attribute (an array with list of custom submit functions) to the form. • Using myform_submit($form, &$form_state) function. • To determine where the user should be sent after the form is processed, the _submit function can place a path or URL in $form_state['redirect'] which will be the target of a drupal_goto. • Every form is redirected after a submit. If nothing stored in $form_state['redirect'], the form will simply be redirected to itself after a submit.
  • 13. Links • http://api.drupal.org • http://api.drupal.org/api/drupal/develope r--topics--forms_api_reference.html/ • http://drupal.org/node/751826
  • 14. Forms in Drupal Oleksandr Masovets E-mail: krasnyj@neformat.com.ua Skype: krasnyjdirex