SlideShare une entreprise Scribd logo
1  sur  14
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

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 2008Rob
 
Creating Multi-Page Data Entry Controllers
Creating Multi-Page Data Entry ControllersCreating Multi-Page Data Entry Controllers
Creating Multi-Page Data Entry ControllersSalesforce Developers
 
Curso Symfony - Clase 3
Curso Symfony - Clase 3Curso Symfony - Clase 3
Curso Symfony - Clase 3Javier 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 BeyondSalesforce Developers
 

Tendances (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
 

En vedette

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-app6891Sylvain Senecal
 
Looking for Vulnerable Code. Vlad Savitsky
Looking for Vulnerable Code. Vlad SavitskyLooking for Vulnerable Code. Vlad Savitsky
Looking for Vulnerable Code. Vlad SavitskyVlad Savitsky
 
Art of Estimation. Vlad Savitsky
Art of Estimation. Vlad SavitskyArt of Estimation. Vlad Savitsky
Art of Estimation. Vlad SavitskyVlad Savitsky
 
Task One: Institutional Research
Task One: Institutional ResearchTask One: Institutional Research
Task One: Institutional ResearchMarni Starr
 

En vedette (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
 

Similaire à Oleksandr Masovets. Forms in Drupal. Drupal Camp Kyiv 2011

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 APIAlexandru Badiu
 
Rapid Prototyping with PEAR
Rapid Prototyping with PEARRapid Prototyping with PEAR
Rapid Prototyping with PEARMarkus Wolff
 
Prateek dayal backbonerails-110528024926-phpapp02
Prateek dayal backbonerails-110528024926-phpapp02Prateek dayal backbonerails-110528024926-phpapp02
Prateek dayal backbonerails-110528024926-phpapp02Revath 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 RailsPrateek 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 - 4DevelopersKacper Gunia
 
Using the Features API
Using the Features APIUsing the Features API
Using the Features APIcgmonroe
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejsNick 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 SimpleAlexander 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 AtlantaChris 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 needKacper 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 exampleKaty 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 fieldIvan 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 modelsKostyantyn Stepanyuk
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Fabien Potencier
 
Breaking the limits_of_page_objects
Breaking the limits_of_page_objectsBreaking the limits_of_page_objects
Breaking the limits_of_page_objectsRobert Bossek
 
Symfony CoP: Form component
Symfony CoP: Form componentSymfony CoP: Form component
Symfony CoP: Form componentSamuel ROZE
 

Similaire à 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
 

Plus de Vlad Savitsky

Css Intro. Vlad Savitsky
Css Intro. Vlad SavitskyCss Intro. Vlad Savitsky
Css Intro. Vlad SavitskyVlad 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 2011Vlad 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 minutesVlad 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 2011Vlad 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 2011Vlad 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 2011Vlad 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 2011Vlad 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 в DrupalVlad Savitsky
 

Plus de 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
 

Dernier

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

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