 | 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
Sameer Borate's Blog: Adding HTML5 'Canvas' element to Wordpress
by Chris Cornutt April 08, 2010 @ 11:22:14
WordPress users that have been interested to explore some of what HTML5 has to offer should check out the latest post from Sameer Borate. He shows how to embed a HTML5 Canvas element you can use to make a "drawable" area of your page. You can test to see if your browser supports it by scrolling to the end of the post.
Only if partially, but HTML 5 is slowly getting increased support from various browsers. Some of the HTML 5 features like '˜canvas' and '˜video' are supported by browsers like Firefox, Safari, Google Chrome and Opera. [...] The Canvas element consists of a drawable region defined in HTML on which you can dynamically draw graphics and animations using Javascript. The canvas API provides a nice set of drawing functions to play with.
His example detects to see if the browser has canvas support (using Modernizr), creates a div container to hold the region and creates a Javascript to define the canvas as a 520 by 220 pixel box. The animation should be loaded automatically.
voice your opinion now!
wordpress canvas html5 element tutorial
Matthew Weier O'Phinney's Blog: Creating composite elements
by Chris Cornutt April 14, 2009 @ 10:25:53
Based on an example in a previous blog post (seen here) Matthew Weier O'Phinney wanted to clear a few things up on the "date of birth" element he had mocked up in his Zend_Form example.
In my last post on decorators, I had an example that showed rendering a "date of birth" element [...]. This has prompted some questions about how this element might be represented as a Zend_Form_Element, as well as how a decorator might be written to encapsulate this logic. Fortunately, I'd already planned to tackle those very subjects for this post!
To be able to use the element in its current state the key lies in the setValue method. More correctly in the overriding of the setValue method. He includes an example class that is smart enough to use that custom form element. It has get and set methods for each of the date fields (month/day/year) and the set/getValue methods that can interact using them. He wraps this all up inside a form decorator and creates an instance of the Date element to help create and handle the properties it has.
voice your opinion now!
create composite element date zendform decorator custom
Jani Hartikainen's Blog: Complex custom elements in Zend_Form
by Chris Cornutt October 23, 2008 @ 12:09:55
In this new post Jani Hartikainen shows a quick and easy method for creating a custom form element in your Zend Framework application. His example is a custom time element.
The alternatives would be creating custom view helpers to output the custom form elements, and using the viewscript decorator. Creating a custom view helper would also require a custom form element class, and it would be a bit tricky. [...] I think the viewscript approach is the most flexible and simplest to implement, so I chose to go with that.
His example defines a time field made up of three drop down lists, one each for hours, minutes and seconds. Included is the code to make the element (including a regular expression for validation) and the view script to display it.
voice your opinion now!
zendform zendframework complex custom element time tutorial
Neil Garb's Blog: Compound elements with Zend_Form
by Chris Cornutt July 17, 2008 @ 11:13:03
In a recent entry to his blog, Neil Garb shows his method for creating compound elements in a Zend_Form object in your Zend Framework website.
Zend_Form can save you a lot of time. It almost completely abstracts away the most boring and error-prone aspects of developing secure and standards-compliant HTML forms. But one thing it doesn't do out of the box is compound elements, such as three-field dates. In this post I'll show you the easiest way to do this ZF-style.
He goes through the creation of the sample controller, an example of a custom element (the multiple date drop-downs he mentioned) and how to handle the validation in a "Zend Framework way" via an isValid call.
voice your opinion now!
compount element zendform zendframework
|
Community Events
Don't see your event here? Let us know!
|