SlideShare una empresa de Scribd logo
1 de 22
Descargar para leer sin conexión
19/10/09 Building Web Applications with Zend Framework 1
Building Web Applications with
Zend Framework
What is Zend Framework?
● A library of useful tools and classes?
● An MVC application framework?
● BOTH
Zend Framework Library
● Yes, it's a little like PEAR
● Huge active community
● High quality code
● Object Oriented PHP5
● Extensively tested
Zend Framework Library
● Advanced, loosely coupled toolset covering a
vast range of utilities, for example
Database Abstraction Table data gateway pattern Cache
Google Data API Adobe AMF Server HTTP Client
LDAP Email OpenID
PDF REST Client & Server Lucene Search
SOAP Internationalisation XMLRPC
Zend Application Framework
● MVC Design Pattern
● Rapid application development using
Zend_Tool command line utility
● Convention over configuration defaults to a
somewhat verbose directory structure however
flexibility allows developers choice
● Features include SEF URLS, custom routes,
context switching and a strong plugin
architecture
Zend Application Framework
● Helper objects are one of the highlights of the
application framework
● Controller Action Helpers for various controller tasks
– URL generation and redirection
– Context Switching
– Flash (single use) messaging
● View Helpers for visual / output encapsulation
– HTML generation
– Pagination
– Navigation
MVC Dispatch Overview
Request
Front Controller
Controller
Plugins
ControllerModels
Controller
Action Helpers
View
View Helpers
Layout
Response
Zend_Tool
● Zend_Tool can be used to
● Create projects
● Add modules, controllers, actions and views using
the default ZF directory structure
● Show information about projects and the PHP
environment
Some Examples
C:UsersPhilworkspace>zf create project phpmelb
Creating project at C:/Users/Phil/workspace/phpmelb
Starting a new project with Zend_Tool
Resulting directory structure
phpmelb
|-- application
| |-- Bootstrap.php
| |-- configs
| | `-- application.ini
| |-- controllers
| | |-- ErrorController.php
| | `-- IndexController.php
| |-- models
| `-- views
| |-- helpers
| `-- scripts
| |-- error
| | `-- error.phtml
| `-- index
| `-- index.phtml
|-- library
|-- public
| `-- index.php
`-- tests
|-- application
| `-- bootstrap.php
|-- library
| `-- bootstrap.php
`-- phpunit.xml
Web Application in a Can
Routes
Default route
:controller/:action/:param/:value/:param/:value...
// or (for modular applications)
:module/:controller/:action/:param/:value/:param/:value...
Custom routes provide ultimate flexibility
// typical “blog” route
:year/:month/:title/:page=1
// with the following defaults
:controller = “article”
:action = “read”
A “module” is simply a collection of controllers, views and custom helper objects.
Plugin Architecture
● Zend Framework supports customisation
through class extension, interface
implementation and plugin loaders
● Plugin loaders let the framework know where to
find custom classes and when to use them
● Controller plugins provide hooks for executing
procedures at any stage in the dispatch cycle
Now for some of my favourites
● ContextSwitch Controller Action Helper
● AjaxContext Controller Action Helper
● Zend_Form
ContextSwitch Controller Action
Helper
● One controller action
● Multiple view scripts depending on “context”
● Actions may be assigned one or more contexts
● Context specified on request using “format”
parameter
● Built-in contexts include
● XML
● JSON
● Developers may add custom contexts
ContextSwitch Helper Example
// application/controllers/IndexController.php
class IndexController extends Zend_Controller_Action
{
public function init()
{
$this->_helper->contextSwitch->addActionContext('index', 'xml')
->initContext();
}
public function indexAction()
{
$this->view->foo = 'foo';
}
}
// application/views/scripts/index.phtml
// Request example “/index/index”
<p>Foo: <?php echo $this->escape($this->foo) ?></p>`
// application/views/scripts/index.xml.phtml
// Request example “/index/index/format/xml”
<root>
<foo><?php echo $this->escape($this->foo) ?></foo>
</root>
AjaxContext Controller Action
Helper
● Extends ContextSwitch Helper
● Adds “html” context
● Only fires on AJAX requests
● Detects using X_REQUESTED_WITH HTTP
header
● Disables any layouts
● Perfect for loading HTML “snippets”
AjaxContext Helper Example
// application/controllers/IndexController.php
class IndexController extends Zend_Controller_Action
{
public function init()
{
$this->_helper->ajaxContext->addActionContext('index', 'html')
->initContext();
}
public function indexAction()
{
$this->view->foo = 'foo';
}
}
// application/views/scripts/index.phtml
<table>
<tr>
<td>Foo</td>
<td><?php echo $this->escape($this->foo) ?></td>
</tr>
</table>
// application/views/scripts/index.ajax.phtml
// Only the output below is sent in the response
<td>Foo</td>
<td><?php echo $this->escape($this->foo) ?></td>
Zend_Form
● One of the most powerful web application
development components
● Combines
● Form HTML generation
● Input filtering
● Input validation
● AJAX validation for client-side hooks
● Internationalisation
● Error handling and message display
Building Forms
● Forms can be built in code or from config files
● XML
● .ini
● PHP Array
● Form appearance dictated by “decorators”
● Decorators provide infinite markup possibilities
without effecting form logic
Zend_Form Example
$form = new Zend_Form;
$form->addElement('text', 'foo', array(
'label' => 'Foo',
'required' => true,
'filters' => array('StringTrim')
))->addElement('textarea', 'bar', array(
'label' => 'Bar',
'cols' => 60,
'rows' => 5,
'validators' => array(
array('StringLength', false, array(0, 50))
)
))->addElement('submit', 'submit_btn', array(
'label' => 'Submit'
))->addDisplayGroup(
array('foo', 'bar', 'submit_btn'),
'my_fieldset',
array('legend' => 'My Form')
);
Zend_Form Example
Validators In Action

Más contenido relacionado

La actualidad más candente

ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC
eldorina
 
ColdFusion framework comparison
ColdFusion framework comparisonColdFusion framework comparison
ColdFusion framework comparison
VIkas Patel
 
SoCal Code Camp 2011 - ASP.NET 4.5
SoCal Code Camp 2011 - ASP.NET 4.5SoCal Code Camp 2011 - ASP.NET 4.5
SoCal Code Camp 2011 - ASP.NET 4.5
Jon Galloway
 
PHP MVC Tutorial
PHP MVC TutorialPHP MVC Tutorial
PHP MVC Tutorial
Yang Bruce
 

La actualidad más candente (20)

Mortal Kombat! ASP.NET MVC vs ASP.NET Webforms – ASP.NET MVC is amazing
Mortal Kombat! ASP.NET MVC vs ASP.NET Webforms – ASP.NET MVC is amazingMortal Kombat! ASP.NET MVC vs ASP.NET Webforms – ASP.NET MVC is amazing
Mortal Kombat! ASP.NET MVC vs ASP.NET Webforms – ASP.NET MVC is amazing
 
Mastering asp.net mvc - Dot Net Tricks
Mastering asp.net mvc - Dot Net TricksMastering asp.net mvc - Dot Net Tricks
Mastering asp.net mvc - Dot Net Tricks
 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC
 
Burlington, VT PHP Users Group Subversion Presentation
Burlington, VT PHP Users Group Subversion PresentationBurlington, VT PHP Users Group Subversion Presentation
Burlington, VT PHP Users Group Subversion Presentation
 
ColdFusion framework comparison
ColdFusion framework comparisonColdFusion framework comparison
ColdFusion framework comparison
 
Exploring AngularJS - Liju Pillai
Exploring AngularJS - Liju PillaiExploring AngularJS - Liju Pillai
Exploring AngularJS - Liju Pillai
 
When to use and when not to use AngularJS - Liju Pillai, www.perfomatix.com
When to use and when not to use AngularJS - Liju Pillai, www.perfomatix.comWhen to use and when not to use AngularJS - Liju Pillai, www.perfomatix.com
When to use and when not to use AngularJS - Liju Pillai, www.perfomatix.com
 
Introduction to CodeIgniter
Introduction to CodeIgniterIntroduction to CodeIgniter
Introduction to CodeIgniter
 
RequireJS
RequireJSRequireJS
RequireJS
 
Introduction To CodeIgniter
Introduction To CodeIgniterIntroduction To CodeIgniter
Introduction To CodeIgniter
 
Ch. 11 deploying
Ch. 11 deployingCh. 11 deploying
Ch. 11 deploying
 
Session 28 - Servlets - Part 4
Session 28 - Servlets - Part 4Session 28 - Servlets - Part 4
Session 28 - Servlets - Part 4
 
Having fun with code igniter
Having fun with code igniterHaving fun with code igniter
Having fun with code igniter
 
Require JS
Require JSRequire JS
Require JS
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015
 
asp-net.pptx
asp-net.pptxasp-net.pptx
asp-net.pptx
 
4. Introduction to ASP.NET MVC - Part I
4. Introduction to ASP.NET MVC - Part I4. Introduction to ASP.NET MVC - Part I
4. Introduction to ASP.NET MVC - Part I
 
SoCal Code Camp 2011 - ASP.NET 4.5
SoCal Code Camp 2011 - ASP.NET 4.5SoCal Code Camp 2011 - ASP.NET 4.5
SoCal Code Camp 2011 - ASP.NET 4.5
 
PHP MVC Tutorial
PHP MVC TutorialPHP MVC Tutorial
PHP MVC Tutorial
 
Sightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVASightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVA
 

Similar a Building Web Applications with Zend Framework

Edp bootstrapping a-software_company
Edp bootstrapping a-software_companyEdp bootstrapping a-software_company
Edp bootstrapping a-software_company
Ganesh Kulkarni
 
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
King Foo
 
Benefit of CodeIgniter php framework
Benefit of CodeIgniter php frameworkBenefit of CodeIgniter php framework
Benefit of CodeIgniter php framework
Bo-Yi Wu
 
PHP
PHPPHP

Similar a Building Web Applications with Zend Framework (20)

Edp bootstrapping a-software_company
Edp bootstrapping a-software_companyEdp bootstrapping a-software_company
Edp bootstrapping a-software_company
 
Zend Framework Quick Start Walkthrough
Zend Framework Quick Start WalkthroughZend Framework Quick Start Walkthrough
Zend Framework Quick Start Walkthrough
 
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
 
Building and managing applications fast for IBM i
Building and managing applications fast for IBM iBuilding and managing applications fast for IBM i
Building and managing applications fast for IBM i
 
Memphis php 01 22-13 - laravel basics
Memphis php 01 22-13 - laravel basicsMemphis php 01 22-13 - laravel basics
Memphis php 01 22-13 - laravel basics
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API Changes
 
Zend Framework
Zend FrameworkZend Framework
Zend Framework
 
Improving QA on PHP projects - confoo 2011
Improving QA on PHP projects - confoo 2011Improving QA on PHP projects - confoo 2011
Improving QA on PHP projects - confoo 2011
 
Laravel & Composer presentation - WebHostFace
Laravel & Composer presentation - WebHostFace Laravel & Composer presentation - WebHostFace
Laravel & Composer presentation - WebHostFace
 
REST API Best Practices & Implementing in Codeigniter
REST API Best Practices & Implementing in CodeigniterREST API Best Practices & Implementing in Codeigniter
REST API Best Practices & Implementing in Codeigniter
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Red5 - PHUG Workshops
Red5 - PHUG WorkshopsRed5 - PHUG Workshops
Red5 - PHUG Workshops
 
Benefit of CodeIgniter php framework
Benefit of CodeIgniter php frameworkBenefit of CodeIgniter php framework
Benefit of CodeIgniter php framework
 
Laravel & Composer presentation - extended
Laravel & Composer presentation - extendedLaravel & Composer presentation - extended
Laravel & Composer presentation - extended
 
PHP
PHPPHP
PHP
 
Getting Started with Zend Framework
Getting Started with Zend FrameworkGetting Started with Zend Framework
Getting Started with Zend Framework
 
Routing
RoutingRouting
Routing
 
Headless approach for offloading heavy tasks in Magento
Headless approach for offloading heavy tasks in MagentoHeadless approach for offloading heavy tasks in Magento
Headless approach for offloading heavy tasks in Magento
 
Intro to drupal_7_architecture
Intro to drupal_7_architectureIntro to drupal_7_architecture
Intro to drupal_7_architecture
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

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...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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, ...
 
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...
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

Building Web Applications with Zend Framework

  • 1. 19/10/09 Building Web Applications with Zend Framework 1 Building Web Applications with Zend Framework
  • 2. What is Zend Framework? ● A library of useful tools and classes? ● An MVC application framework? ● BOTH
  • 3. Zend Framework Library ● Yes, it's a little like PEAR ● Huge active community ● High quality code ● Object Oriented PHP5 ● Extensively tested
  • 4. Zend Framework Library ● Advanced, loosely coupled toolset covering a vast range of utilities, for example Database Abstraction Table data gateway pattern Cache Google Data API Adobe AMF Server HTTP Client LDAP Email OpenID PDF REST Client & Server Lucene Search SOAP Internationalisation XMLRPC
  • 5. Zend Application Framework ● MVC Design Pattern ● Rapid application development using Zend_Tool command line utility ● Convention over configuration defaults to a somewhat verbose directory structure however flexibility allows developers choice ● Features include SEF URLS, custom routes, context switching and a strong plugin architecture
  • 6. Zend Application Framework ● Helper objects are one of the highlights of the application framework ● Controller Action Helpers for various controller tasks – URL generation and redirection – Context Switching – Flash (single use) messaging ● View Helpers for visual / output encapsulation – HTML generation – Pagination – Navigation
  • 7. MVC Dispatch Overview Request Front Controller Controller Plugins ControllerModels Controller Action Helpers View View Helpers Layout Response
  • 8. Zend_Tool ● Zend_Tool can be used to ● Create projects ● Add modules, controllers, actions and views using the default ZF directory structure ● Show information about projects and the PHP environment
  • 9. Some Examples C:UsersPhilworkspace>zf create project phpmelb Creating project at C:/Users/Phil/workspace/phpmelb Starting a new project with Zend_Tool Resulting directory structure phpmelb |-- application | |-- Bootstrap.php | |-- configs | | `-- application.ini | |-- controllers | | |-- ErrorController.php | | `-- IndexController.php | |-- models | `-- views | |-- helpers | `-- scripts | |-- error | | `-- error.phtml | `-- index | `-- index.phtml |-- library |-- public | `-- index.php `-- tests |-- application | `-- bootstrap.php |-- library | `-- bootstrap.php `-- phpunit.xml
  • 11. Routes Default route :controller/:action/:param/:value/:param/:value... // or (for modular applications) :module/:controller/:action/:param/:value/:param/:value... Custom routes provide ultimate flexibility // typical “blog” route :year/:month/:title/:page=1 // with the following defaults :controller = “article” :action = “read” A “module” is simply a collection of controllers, views and custom helper objects.
  • 12. Plugin Architecture ● Zend Framework supports customisation through class extension, interface implementation and plugin loaders ● Plugin loaders let the framework know where to find custom classes and when to use them ● Controller plugins provide hooks for executing procedures at any stage in the dispatch cycle
  • 13. Now for some of my favourites ● ContextSwitch Controller Action Helper ● AjaxContext Controller Action Helper ● Zend_Form
  • 14. ContextSwitch Controller Action Helper ● One controller action ● Multiple view scripts depending on “context” ● Actions may be assigned one or more contexts ● Context specified on request using “format” parameter ● Built-in contexts include ● XML ● JSON ● Developers may add custom contexts
  • 15. ContextSwitch Helper Example // application/controllers/IndexController.php class IndexController extends Zend_Controller_Action { public function init() { $this->_helper->contextSwitch->addActionContext('index', 'xml') ->initContext(); } public function indexAction() { $this->view->foo = 'foo'; } } // application/views/scripts/index.phtml // Request example “/index/index” <p>Foo: <?php echo $this->escape($this->foo) ?></p>` // application/views/scripts/index.xml.phtml // Request example “/index/index/format/xml” <root> <foo><?php echo $this->escape($this->foo) ?></foo> </root>
  • 16. AjaxContext Controller Action Helper ● Extends ContextSwitch Helper ● Adds “html” context ● Only fires on AJAX requests ● Detects using X_REQUESTED_WITH HTTP header ● Disables any layouts ● Perfect for loading HTML “snippets”
  • 17. AjaxContext Helper Example // application/controllers/IndexController.php class IndexController extends Zend_Controller_Action { public function init() { $this->_helper->ajaxContext->addActionContext('index', 'html') ->initContext(); } public function indexAction() { $this->view->foo = 'foo'; } } // application/views/scripts/index.phtml <table> <tr> <td>Foo</td> <td><?php echo $this->escape($this->foo) ?></td> </tr> </table> // application/views/scripts/index.ajax.phtml // Only the output below is sent in the response <td>Foo</td> <td><?php echo $this->escape($this->foo) ?></td>
  • 18. Zend_Form ● One of the most powerful web application development components ● Combines ● Form HTML generation ● Input filtering ● Input validation ● AJAX validation for client-side hooks ● Internationalisation ● Error handling and message display
  • 19. Building Forms ● Forms can be built in code or from config files ● XML ● .ini ● PHP Array ● Form appearance dictated by “decorators” ● Decorators provide infinite markup possibilities without effecting form logic
  • 20. Zend_Form Example $form = new Zend_Form; $form->addElement('text', 'foo', array( 'label' => 'Foo', 'required' => true, 'filters' => array('StringTrim') ))->addElement('textarea', 'bar', array( 'label' => 'Bar', 'cols' => 60, 'rows' => 5, 'validators' => array( array('StringLength', false, array(0, 50)) ) ))->addElement('submit', 'submit_btn', array( 'label' => 'Submit' ))->addDisplayGroup( array('foo', 'bar', 'submit_btn'), 'my_fieldset', array('legend' => 'My Form') );