Another year is over, and as is becoming a tradition, I like to show off some photos that recap my year!\ January We started the year with a visit to the zoo! There was also snowy weather last January and on the last day of the month, we put our house on the market. We would be accepting an offer on it in late October. February In February, I took pictures of canal boats. The… continue reading.
If you have a Zend Framework Front Controller plugin which throws an exception, then the action is still executed and then the error action is then called, so that the displayed output shows two actions rendered, with two layouts also rendered. This is almost certainly not what you want or what you expected. This is how to handle errors in a Front Controller plugin: Prefer preDispatch() over dispatchLoopStartup() as it is called from within the… continue reading.
David Papadogiannakis has posted a new article on the new features for forms with HTML5 and how it applies to Zend Framework's Zend_Form component. HTML4 had a few different input elements that could be added to your form : text, password, hidden, checkboxes etc. HTML5 brings even more types that can be added to your <input> tag. He then goes on to provide an override to Zend_Form_Element_Text showing how to use the new attributes with… continue reading.
I came across a situation last week where I needed to access a view helper that was in the default module's views/helpers directory when I was in another module. This came about because my layout.phtml uses a view helper that is in application/views/helpers. By default, it doesn't work and you get an error along the lines of:
Plugin by name 'LoggedInAs' was not found in the registry; used paths:
The fix is simple enough. All you need to do is add this line to your application.ini… continue reading.
I know that everyone already knows this, but I happened to find out for myself recently! I was looking at the way view helpers work in ZF2 and thought it would be more convenient if we altered the syntax a little. A side-effect of the change was that we'd have to use call_user_func_array, which is perceived as slow. I thought I'd whip up a simple test to find out how much slower it would be… continue reading.
A friend of mine recently had a requirement where she wanted to have two config files loaded into Zend_Application, so that the specific settings for the server were not stored in the version control system. Hence she has two config files: application.ini and local.ini where local.ini is different on each server. Update: As takeshin points out with ZF 1.10 or later, an easier solution to this is to pass both ini files into Zend_Application: $application… continue reading.
I recently updated my use of SQL Server with Zend_Db_Adapter_Sqlsrv to use UTF-8 throughout. This turned out to be easy enough: Use ntext, nvarchar types in the database add: resources.db.params.driver_options.CharacterSet = "UTF-8" to your application.ini I subsequently noticed a problem with storing binary data to a varbinary(max) field. The error was: An error occurred translating string for input param 2 to UCS-2: No mapping for the Unicode character exists in the target multi-byte code page.… continue reading.
Ralph has just posted an excellent article on how many to many relationships work with Zend_Db_Table: Basically, I’ve created a single class that effectively take the place of Zend_Db_Table_Row::findManyToManyRowset() for the purposes of creating an iterable rowset that allows access to both the target many-to-many rowset as well as the junction rowset. This solution is called a Composite Rowset. In this solution, both rowsets (iterators) are kept in sync with one another. This proves to… continue reading.
I'm sure everyone else already knows this, but I've recently discovered that Zend_Validate_PostCode doesn't work with UK postcodes unless you first remove the space between the first and second parts. This is due to a bug in the underlying regular expresssions that are provided by CLDR. It's easy enough to add a filter to remove the space, but I'm a little worried that when (and if) it gets fixed, will the fixed version Zend_Validate_PostCode then… continue reading.
I discovered recently that Zend Framework 1's Zend_Date has two operating modes when it comes to format specifiers: iso and php, where iso is the default. When using Zend_Validate_Date in forms, I like to use the php format specifiers as they are what I'm used to and so can easily know what they mean when reviewing code that I wrote months ago. My code looks something like this: $subForm->addElement('text', 'start_date', array( 'filters' => array('StringTrim', 'StripTags'),… continue reading.