 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
PHPMaster.com: Setting Custom Error Messages for Zend_Form_Element
by Chris Cornutt October 11, 2012 @ 08:58:37
On PHPMaster.com today there's a new post for all the Zend Framework (v1) users out there. In it, Aurelio De Rosa shows you how to set custom error messages for elements in a Zend_Form.
In this article I'll show the solution to a common problem which arises when a developer has to create a non-English website or application that is based on the Zend Framework. How do we mark a field of a Zend_Form which is a Zend_Form_Element as invalid, showing one or more custom error messages? The problem is mainly caused by the native counter-intuitive methods of the Zend_Form_Element class which I'll explain in more details.
He's included a basic example showing the creation of a form and the setup of a text element and some validators to match. He makes a controller and view to handle the output and submission then shows how to use "setErrors" (and "setErrorMessages") of the Zend_Form elements to setup that custom error. This only lets you set one message, though, regardless of the point of failure. To stop things when there's an error, you have to set the "breakChainOnFailure" parameter on the validator to false - then the message will make more sense.
voice your opinion now!
zendframework1 zendform custom error message element tutorial
TechPortal: Custom Zend Framework Form Elements
by Chris Cornutt August 01, 2012 @ 08:28:00
In this new post to the TechPortal, Gavin Corbett introduces you to Zend_Form elements (a part of the Zend Framework, v1) and how to create a custom one.
Creating forms in Zend Framework (ZF) is easy, but creating and managing complex forms can get messy! Using config files is perfectly good if you use standard Zend Form elements; it is quick and easy to setup a form in a few minutes however you will have limited control over how the form is rendered. If you want to display your own custom form element correctly in Zend Framework then some configuration is needed in order to achieve this with a config file.
He includes an example of first creating a basic form with a header and a single field element and validating the results of the submission. Building on that, he shows you how to create a custom "EmailAddress" form element and how to add in a view helper to style the output a bit.
voice your opinion now!
zendframework zendform element custom tutorial
MaltBlue.com: Zend Form Mastery with Zend Config - Part 4 Configuring Zend Validators
by Chris Cornutt June 05, 2012 @ 11:25:45
On the MaltBlue blog Matt has posted the latest part of the "Zend_Form with Zend_Config" series, part four looking at using and configuring some form validators.
Welcome to the fourth and final part in the Zend Form Mastery with Zend Config series. Previously we looked at the basic form options, element and form wide prefixes, filters and element options. In this installment, we're going to look at configuring Zend Validators via our XML config. [...] To go in to all of them will take more time than is allowed in the confines of this article. So we're going to work through 5 of the more interesting and likely used ones.
He covers the validation for: email addresses, postal codes, seeing if a record exists in the database, IBAN validation and checking to see if a value is in an array. He gives XML examples for each of these validation methods including the definitions of options and error/feedback messages.
voice your opinion now!
zendform zendconfig configure validator tutorial xml
MaltBlue.com: Zend Form Mastery with Zend_Config - Part 2, Core Form Configuration
by Chris Cornutt May 15, 2012 @ 11:04:01
In his previous post to the MaltBlue.com blog Matt introduced the concept of configuration-driven Zend_Form instances. He's back with a second part to the series, enhancing his original examples by covering some of the base-level form configuration settings.
Ok, this should have been part one, but irrespective, here's the second installment in zend form mastery with zend config - core form configuration. As the W3c Form spec says, there are 8 attributes applicable to forms.
These attributes, including "action", "name" and "onsubmit", can all be set easily in the XML-based configuration file. He includes an example of the full XML file to show how they all fit together (updated from part 1). You can see an example of the output here and can grab the source for the example from github.
voice your opinion now!
zendframework zendconfig zendform generation xml tutorial
MaltBlue.com: Zend Form Mastery with Zend Config - Part 1, Custom Filter Paths
by Chris Cornutt April 30, 2012 @ 08:16:22
From MaltBlue.com there's a new post (the first in a series) about mastering Zend_Form. In this first part of the series, they look at creating custom filter paths with the help of the Zend_Config component.
When you're working with Zend Framework, and code in general, you keep your configuration as much out of code as you can - right? Well, if you want to write maintainable and flexible code you do. Well, if you've been working with Zend Framework and Zend Form for more than a little while, you know that it really makes that pretty simple via Zend_Config - well, some of the time.
The article shows introduces you to some of the common configuration settings of Zend_Form and how those can be set in a configuration to make building the forms simpler. They talk about pre-element and form-wide filters in this first part of the series, including some code/configuration examples.
voice your opinion now!
zendframework zendform zendconfig configuration tutorial
Odafe Ojenikoh's Blog: Interactive PHP CLI Applications using Zend Form
by Chris Cornutt February 16, 2012 @ 11:09:57
Odafe Ojenikoh has submitted a post he's written up showing how to create a command line PHP application with the help of the Zend Framework and it's Zend_Form elements.
Over the weekend, I was toying with the idea of interactive cli applications using readline() and Zend Form for validating input. My motivation for using Zend Form or rather Zend Form elements was to exploit the power of features such as labels, validators, filters and the prospect of reusing forms within web application code.
His example code defines a Filter for the form errors (returning them as a string) and a "Cli" class that handles the interaction with the command line. Next up is a class defining the form elements - a prompt for a color name and either of the words "thank" and "you". The Cli class transforms the form elements into prompts on the command line and lets you define validators to check their input.
voice your opinion now!
zendform zendframework cli commandline application tutorial
Jason Gilmore's Blog: How I Learned to Stop Worrying and Love Zend_Form
by Chris Cornutt August 22, 2011 @ 13:57:14
On his blog today Jason Gilmore has a quick post about solving one of his frustrations with Zend_Form (a part of the Zend Framework) - the default form decorators.
It is a fantastically productive framework, one which I happen to use almost every single day. There was however one feature which absolutely drove me crazy. The Zend_Form component's uses the dd, dl, and dt elements as the default form markup decorators, meaning that even a simple contact form consisting of name, email, and message fields and a submit button [is marked up with dl, dt and dds]. [...] It goes without saying that the overwhelming majority of developers do not use these elements to mark up their forms, with the sheer number of questions posted to StackOverflow and elsewhere about getting rid of these decorators backing this assertion.
He gives his simple solution to the issue, something better than removing all of the decorators and using setDecorator to replace them - a simple partial view that echos out the fields directly. The trick is to use the setDecorators call with a "ViewScript" option pointing to your partial and setElementDecorators() call to use a "ViewHelper".
voice your opinion now!
zendform tutorial markup decorator form
|
Community Events
Don't see your event here? Let us know!
|