SlideShare a Scribd company logo
by Tya Herlina
• Zend_Form is library in Zend Framework for creating
form object.
• Why Zend_Form 1.7?
• In Buzoo Indonesia, we use Zend Framework version 1.7
• HOW to?
$form = new Zend_Form();
• Simplifies form creation,
• Simplifies form handling in your web application.
• Element input filtering and validation
• Element ordering
• Element and Form rendering, including escaping
• Element and form grouping
• Element and form-level configuration
It heavily leverages other Zend Framework components to
accomplish its goals, including :
• Zend_Config
• Zend_Validate
• Zend_Filter
• Zend_Loader_PluginLoader
• Zend_View [optionally]
• button
• checkbox
• multicheckbox
• hidden
• image
• password
• radio
• reset
• select
• submit
• text
• textarea
• etc (see
Zend_Form_Element_*)
• Alnum
• Alpha
• Date
• Digits
• EmailAddress
• StringLength
• Regex
• Etc (See Zend_Validate_*)
• getElement($name)
• getElements() setDefaults(array $defaults)
• setDefault($name, $value)
• getValue($name)
• getValues()
• etc
• Example ---- We want to register account in :
www.buzoolecture.com/register/form
• Registration Form
• Nickname (Required, Min. 6 char, Max. 10 char, must be Alpha
and Number)
• Gender (Required)
• Phone (Required, must be number)
• Email Address (Required)
• Password (Required)
• Confirmation Password (Required, must be same with Password)
• Enables developers to store configuration data in a familiar INI
format and read them in the application by using nested object
property syntax.
$config = new Zend_Config_Ini('/path/to/config.ini',
„section_name„, $options);
• By default, the key separator character is the period character
(.)
• This can be changed :
$options['nestSeparator'] = ':';
• Comments start with (;), as in php.ini
• Zend_Config_Ini utilizes the parse_ini_file() PHP function.
• Example : http://id1.php.net/parse_ini_file
[form]
register.form.action = "/dietitian/register/form"
register.form.method = "post"
; nickname
register.form.elements.nickname.type = "text"
register.form.elements.nickname.options.required = true
register.form.elements.nickname.options.validators.alnum.validator =
"Alnum"
register.form.elements.nickname.options.validators.strlen.validator =
"StringLength"
register.form.elements.nickname.options.validators.strlen.options.min =
"6"
register.form.elements.nickname.options.validators.strlen.options.max =
"10"
register.form.elements.nickname.errors.isEmpty = "Must be filled."
register.form.elements.nickname.errors.other = "Please enter correctly."
; gender
register.form.elements.gender.type = "radio"
register.form.elements.gender.options.required = true
register.form.elements.gender.errors.isEmpty = "Must be filled."
register.form.elements.gender.errors.other = "Please choose correctly."
; phone
register.form.elements.phone.type = "text"
register.form.elements.phone.options.required = true
register.form.elements.phone.options.validators.digits.validator =
"Digits"
register.form.elements.phone.errors.isEmpty = "Must be filled."
register.form.elements.phone.errors.other = "Please enter correctly.“
; email
register.form.elements.email.type = "text"
register.form.elements.email.options.required = true
register.form.elements.email.options.validators.email.validator =
"EmailAddress"
register.form.elements.email.errors.isEmpty = "Must be filled."
register.form.elements.email.errors.other = "Please enter correctly."
; password
register.form.elements.password.type = "password"
register.form.elements.password.options.required = true
register.form.elements.password.errors.place = "err_password"
register.form.elements.password.errors.isEmpty = "Must be filled."
register.form.elements.password.errors.other = "Please enter correctly."
; conf_password
register.form.elements.conf_password.type = "password"
register.form.elements.conf_password.options.required = true
register.form.elements.conf_password.errors.place = "err_password"
register.form.elements.conf_password.errors.isEmpty = "Must be filled."
register.form.elements.conf_password.errors.other = "Please enter
correctly."
public function formAction() {
//get register.ini file
$config = new Zend_Config_Ini(„/path/to/register.ini‟, 'form');
//define form
$form = new Zend_Form($config->register->form);
$this->view->form = $form;
//set option for element gender
$form->getElement('gender')->setMultiOptions(array('1' => 'Male', '2' => 'Female'));
$form->getElement('gender')->setSeparator(' ');
//if submit button pressed
if ( $this->getRequest()->isPost() ) {
//isValid is function from Zend
if ($form->isValid($_POST) ) {
//get value for checking confirmation password must be same with password
if( $form->getValue(„password‟) == $form->getValue(„conf_password‟) ) {
echo “Complete!!”;
} else {
echo “Ups, Sorry! Confirmation Password must be same with Password”;
}
}
}
}
<form action="/register/form" method="post" name="form1" id="form1">
Nickname : <?= $this->form->getElement('nickname') ?><br>
Gender : <?= $this->form->getElement('gender') ?><br>
Phone : <?= $this->form->getElement('phone') ?><br>
Email : <?= $this->form->getElement('email') ?><br>
Password : <?= $this->form->getElement('password') ?><br>
Confirmation Password<?= $this->form->getElement(„conf_password') ?><br>
<input type="submit" value="Register"/>
</form>
More information can be found at the Zend Framework
website
http://framework.zend.com/manual/1.7/en/index.html
Thank you~

More Related Content

Recently uploaded

How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
S. Raj Kumar
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Diana Rendina
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 

Recently uploaded (20)

How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
Alireza Esmikhani
 

Featured (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

Zend Form 1.7 Tutorial [PT.Buzoo Indonesia]

  • 2. • Zend_Form is library in Zend Framework for creating form object. • Why Zend_Form 1.7? • In Buzoo Indonesia, we use Zend Framework version 1.7 • HOW to? $form = new Zend_Form();
  • 3. • Simplifies form creation, • Simplifies form handling in your web application.
  • 4. • Element input filtering and validation • Element ordering • Element and Form rendering, including escaping • Element and form grouping • Element and form-level configuration It heavily leverages other Zend Framework components to accomplish its goals, including : • Zend_Config • Zend_Validate • Zend_Filter • Zend_Loader_PluginLoader • Zend_View [optionally]
  • 5. • button • checkbox • multicheckbox • hidden • image • password • radio • reset • select • submit • text • textarea • etc (see Zend_Form_Element_*)
  • 6. • Alnum • Alpha • Date • Digits • EmailAddress • StringLength • Regex • Etc (See Zend_Validate_*)
  • 7. • getElement($name) • getElements() setDefaults(array $defaults) • setDefault($name, $value) • getValue($name) • getValues() • etc
  • 8. • Example ---- We want to register account in : www.buzoolecture.com/register/form • Registration Form • Nickname (Required, Min. 6 char, Max. 10 char, must be Alpha and Number) • Gender (Required) • Phone (Required, must be number) • Email Address (Required) • Password (Required) • Confirmation Password (Required, must be same with Password)
  • 9. • Enables developers to store configuration data in a familiar INI format and read them in the application by using nested object property syntax. $config = new Zend_Config_Ini('/path/to/config.ini', „section_name„, $options); • By default, the key separator character is the period character (.) • This can be changed : $options['nestSeparator'] = ':'; • Comments start with (;), as in php.ini • Zend_Config_Ini utilizes the parse_ini_file() PHP function. • Example : http://id1.php.net/parse_ini_file
  • 10. [form] register.form.action = "/dietitian/register/form" register.form.method = "post" ; nickname register.form.elements.nickname.type = "text" register.form.elements.nickname.options.required = true register.form.elements.nickname.options.validators.alnum.validator = "Alnum" register.form.elements.nickname.options.validators.strlen.validator = "StringLength" register.form.elements.nickname.options.validators.strlen.options.min = "6" register.form.elements.nickname.options.validators.strlen.options.max = "10" register.form.elements.nickname.errors.isEmpty = "Must be filled." register.form.elements.nickname.errors.other = "Please enter correctly." ; gender register.form.elements.gender.type = "radio" register.form.elements.gender.options.required = true register.form.elements.gender.errors.isEmpty = "Must be filled." register.form.elements.gender.errors.other = "Please choose correctly." ; phone register.form.elements.phone.type = "text" register.form.elements.phone.options.required = true register.form.elements.phone.options.validators.digits.validator = "Digits" register.form.elements.phone.errors.isEmpty = "Must be filled." register.form.elements.phone.errors.other = "Please enter correctly.“ ; email register.form.elements.email.type = "text" register.form.elements.email.options.required = true register.form.elements.email.options.validators.email.validator = "EmailAddress" register.form.elements.email.errors.isEmpty = "Must be filled." register.form.elements.email.errors.other = "Please enter correctly." ; password register.form.elements.password.type = "password" register.form.elements.password.options.required = true register.form.elements.password.errors.place = "err_password" register.form.elements.password.errors.isEmpty = "Must be filled." register.form.elements.password.errors.other = "Please enter correctly." ; conf_password register.form.elements.conf_password.type = "password" register.form.elements.conf_password.options.required = true register.form.elements.conf_password.errors.place = "err_password" register.form.elements.conf_password.errors.isEmpty = "Must be filled." register.form.elements.conf_password.errors.other = "Please enter correctly."
  • 11. public function formAction() { //get register.ini file $config = new Zend_Config_Ini(„/path/to/register.ini‟, 'form'); //define form $form = new Zend_Form($config->register->form); $this->view->form = $form; //set option for element gender $form->getElement('gender')->setMultiOptions(array('1' => 'Male', '2' => 'Female')); $form->getElement('gender')->setSeparator(' '); //if submit button pressed if ( $this->getRequest()->isPost() ) { //isValid is function from Zend if ($form->isValid($_POST) ) { //get value for checking confirmation password must be same with password if( $form->getValue(„password‟) == $form->getValue(„conf_password‟) ) { echo “Complete!!”; } else { echo “Ups, Sorry! Confirmation Password must be same with Password”; } } } }
  • 12.
  • 13. <form action="/register/form" method="post" name="form1" id="form1"> Nickname : <?= $this->form->getElement('nickname') ?><br> Gender : <?= $this->form->getElement('gender') ?><br> Phone : <?= $this->form->getElement('phone') ?><br> Email : <?= $this->form->getElement('email') ?><br> Password : <?= $this->form->getElement('password') ?><br> Confirmation Password<?= $this->form->getElement(„conf_password') ?><br> <input type="submit" value="Register"/> </form>
  • 14. More information can be found at the Zend Framework website http://framework.zend.com/manual/1.7/en/index.html