Your SlideShare is downloading. ×
Zend Form 1.7 Tutorial [PT.Buzoo Indonesia]
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Zend Form 1.7 Tutorial [PT.Buzoo Indonesia]

254
views

Published on

We are having computer technology lecture frequently at PT.Buzoo Indonesia. …

We are having computer technology lecture frequently at PT.Buzoo Indonesia.
Today topic is about learn Zend Framework.

The section talk about how to use or tutorial Zend Form.
Zend_Form is library in Zend Framework for creating form object.

One of our PHP Team, Tya Herlina, will presenting this section.

We hope all of you guys enjoy this lecture section with this online presentation.

If you want know about PT. Buzoo Indonesia, Please visit our website : http://buzoo.co.id

Published in: Education, Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
254
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. by Tya Herlina
  • 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. <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>
  • 13. More information can be found at the Zend Framework website http://framework.zend.com/manual/1.7/en/index.html
  • 14. Thank you~