SlideShare a Scribd company logo
1 of 28
Moodle Quick Forms Moodle - lib/formslib
Contents ,[object Object],[object Object],[object Object],[object Object]
Introduction to Moodle_QuickForm ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Cont… ,[object Object],[object Object],[object Object],[object Object]
Cont… ,[object Object],[object Object],[object Object],[object Object],[object Object]
Usage
Definition ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
definition()
addElement() Syntax : $form->addElement  ( type, name, label, …) Example : ,[object Object],[object Object],[object Object],[object Object]
closeHeaderBefore() Syntax : $form->closeHeaderBefore ( element_name )
setHelpButton() Syntax : $form->setHelpButton ( element_name,  array( help_filename, title, module), supress_check ) $mform->setHelpButton(' questionsperpage ',  array( ' questionsperpage ',  get_string(  ' questionsperpage ',  ' quiz ' ),  ' quiz '  ) ) Example :
addGroup() ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],A 'group' in formslib is just a group of elements that will have a  label and will be included on one line.  Def :
setType() ,[object Object],[object Object],Syntax : $form->setType ( element_name, type) Example :
Most Commonly Used PARAM_* Types : alias of PARAM_ALPHA and is used for hidden fields specifying form actions  PARAM_ACTION Used for Integers PARAM_INT ,[object Object],[object Object],PARAM_RAW ,[object Object],[object Object],[object Object],PARAM_NOTAGS Cleaning the plain text data. Strips all html tags. PARAM_TEXT Deprecated PARAM_CLEAN
setDefault() ,[object Object],[object Object],Syntax : $form->setDefault ( element_name, default value) Example :
addRule() $mform->addRule (  ‘elementname’,  ‘ error_message’,  ‘ ruletype’,  ‘ external_ruledata’,  ‘ server/client’,  ‘ reset(bool)’ ,  ‘ force(bool)’  ) Syntax : Common Rule Types nonzero  callback  compare  alphanumeric  numeric  nopunctuation  email  regex  lettersonly  required  maxlength  minlength  rangelength
Cont…
add_action_buttons $this->add_action_buttons ( $cancel  = true,  $ submitlabel =null) Syntax : ,[object Object],[object Object],[object Object]
Other ,[object Object],[object Object],After submitting a form, all the form information is get through  get_data()  function. save_files()  function used for that FORM saves all the files uploaded to specified directory.
Cont… ,[object Object],$mform->registerRule ($name , $type , $data1 , $data2 ) $name =  name of function / name of validation rule $type  =  'regex' or 'callback' ('function' is also kept for backward compatibility)  $data1 =   Name of function, regular expression, classname , callback function  needs to return true or false   $data2 =   Object parent of above function, name of the file  Where,
Cont… ,[object Object],$mform->disabledIf ( $elementName,  $dependentOn,    $condition = 'notchecked',  $value=null)  ,[object Object],[object Object],[object Object],[object Object],[object Object]
disabledif() Cont… ,[object Object],[object Object],[object Object],[object Object]
Validation ,[object Object],[object Object],[object Object]
validation() ,[object Object],[object Object],[object Object]
MoodleQuickForm::addRule()  Default error messages are defined in lang/{language}/form.php
moodleform::validation()  $data = contains all the  values set on submitting the value.  $data is array which  contains value in following form:  $data[‘elementname’] Example:  $s = $data[‘shortname’]; $error = is an array which stores error, while validating the submitted data. Syntax:  $error[‘elementname’] Where, elementname should be same as name given while creating form.
Cont… $files in validation function is extra parameter for validating  the files which are to be uploaded to system
References http://docs.moodle.org/en/Category:Formslib http://www.moodle.org/ http://pear.php.net/

More Related Content

What's hot

What's hot (13)

Docslide.com.br sap solucao-nf-e-standard
Docslide.com.br sap solucao-nf-e-standardDocslide.com.br sap solucao-nf-e-standard
Docslide.com.br sap solucao-nf-e-standard
 
PLSQL Cursors
PLSQL CursorsPLSQL Cursors
PLSQL Cursors
 
Oracle Self Service HR Document
Oracle Self Service HR DocumentOracle Self Service HR Document
Oracle Self Service HR Document
 
How to create payslip through self service
How to create payslip through self serviceHow to create payslip through self service
How to create payslip through self service
 
Query all roles and duties and privileges Oracle Fusion Cloud
Query all roles and duties and privileges Oracle Fusion CloudQuery all roles and duties and privileges Oracle Fusion Cloud
Query all roles and duties and privileges Oracle Fusion Cloud
 
Relacionar tablas en SQL
Relacionar tablas en SQLRelacionar tablas en SQL
Relacionar tablas en SQL
 
La ceiba honduras
La ceiba hondurasLa ceiba honduras
La ceiba honduras
 
Estructuras de datos lineales
Estructuras de datos linealesEstructuras de datos lineales
Estructuras de datos lineales
 
All payroll elements with eligibility Oracle Fusion Cloud
All payroll elements with eligibility Oracle Fusion CloudAll payroll elements with eligibility Oracle Fusion Cloud
All payroll elements with eligibility Oracle Fusion Cloud
 
Funções - Tutorial ABAP
Funções - Tutorial ABAPFunções - Tutorial ABAP
Funções - Tutorial ABAP
 
Introducción a sql server
Introducción a sql serverIntroducción a sql server
Introducción a sql server
 
Sql
SqlSql
Sql
 
Easing Reconciling Oracle Inventory and General Ledger with Simplified Proced...
Easing Reconciling Oracle Inventory and General Ledger with Simplified Proced...Easing Reconciling Oracle Inventory and General Ledger with Simplified Proced...
Easing Reconciling Oracle Inventory and General Ledger with Simplified Proced...
 

Similar to Moodle Quick Forms

Testing persistence in PHP with DbUnit
Testing persistence in PHP with DbUnitTesting persistence in PHP with DbUnit
Testing persistence in PHP with DbUnit
Peter Wilcsinszky
 

Similar to Moodle Quick Forms (20)

Framework
FrameworkFramework
Framework
 
Unit testing zend framework apps
Unit testing zend framework appsUnit testing zend framework apps
Unit testing zend framework apps
 
Testing persistence in PHP with DbUnit
Testing persistence in PHP with DbUnitTesting persistence in PHP with DbUnit
Testing persistence in PHP with DbUnit
 
Zend framework 04 - forms
Zend framework 04 - formsZend framework 04 - forms
Zend framework 04 - forms
 
Django Search
Django SearchDjango Search
Django Search
 
Django Forms: Best Practices, Tips, Tricks
Django Forms: Best Practices, Tips, TricksDjango Forms: Best Practices, Tips, Tricks
Django Forms: Best Practices, Tips, Tricks
 
JQuery Presentation
JQuery PresentationJQuery Presentation
JQuery Presentation
 
Drupal Form Api
Drupal Form ApiDrupal Form Api
Drupal Form Api
 
Test driven development_for_php
Test driven development_for_phpTest driven development_for_php
Test driven development_for_php
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBenelux
 
Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018
Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018
Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11
 
Bioinformatica 10-11-2011-p6-bioperl
Bioinformatica 10-11-2011-p6-bioperlBioinformatica 10-11-2011-p6-bioperl
Bioinformatica 10-11-2011-p6-bioperl
 
vfsStream - a better approach for file system dependent tests
vfsStream - a better approach for file system dependent testsvfsStream - a better approach for file system dependent tests
vfsStream - a better approach for file system dependent tests
 
Drupal7 dbtng
Drupal7  dbtngDrupal7  dbtng
Drupal7 dbtng
 
Coding for Scale and Sanity
Coding for Scale and SanityCoding for Scale and Sanity
Coding for Scale and Sanity
 
Custom Signals for Uncoupled Design
Custom Signals for Uncoupled DesignCustom Signals for Uncoupled Design
Custom Signals for Uncoupled Design
 
Views notwithstanding
Views notwithstandingViews notwithstanding
Views notwithstanding
 
Separation of concerns - DPC12
Separation of concerns - DPC12Separation of concerns - DPC12
Separation of concerns - DPC12
 
Php security3895
Php security3895Php security3895
Php security3895
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

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...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

Moodle Quick Forms

  • 1. Moodle Quick Forms Moodle - lib/formslib
  • 2.
  • 3.
  • 4.
  • 5.
  • 7.
  • 9.
  • 10. closeHeaderBefore() Syntax : $form->closeHeaderBefore ( element_name )
  • 11. setHelpButton() Syntax : $form->setHelpButton ( element_name, array( help_filename, title, module), supress_check ) $mform->setHelpButton(' questionsperpage ', array( ' questionsperpage ', get_string( ' questionsperpage ', ' quiz ' ), ' quiz ' ) ) Example :
  • 12.
  • 13.
  • 14.
  • 15.
  • 16. addRule() $mform->addRule ( ‘elementname’, ‘ error_message’, ‘ ruletype’, ‘ external_ruledata’, ‘ server/client’, ‘ reset(bool)’ , ‘ force(bool)’ ) Syntax : Common Rule Types nonzero callback compare alphanumeric numeric nopunctuation email regex lettersonly required maxlength minlength rangelength
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25. MoodleQuickForm::addRule() Default error messages are defined in lang/{language}/form.php
  • 26. moodleform::validation() $data = contains all the values set on submitting the value. $data is array which contains value in following form: $data[‘elementname’] Example: $s = $data[‘shortname’]; $error = is an array which stores error, while validating the submitted data. Syntax: $error[‘elementname’] Where, elementname should be same as name given while creating form.
  • 27. Cont… $files in validation function is extra parameter for validating the files which are to be uploaded to system