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

Zend Form 1.7 Tutorial [PT.Buzoo Indonesia]

on

  • 291 views

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

Statistics

Views

Total Views
291
Views on SlideShare
290
Embed Views
1

Actions

Likes
0
Downloads
4
Comments
0

1 Embed 1

https://twitter.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Zend Form 1.7 Tutorial [PT.Buzoo Indonesia] Zend Form 1.7 Tutorial [PT.Buzoo Indonesia] Presentation Transcript

    • 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~