- July 2010 (1)
- June 2010 (4)
- May 2010 (3)
- April 2010 (6)
- March 2010 (6)
- February 2010 (8)
- January 2010 (13)
- December 2009 (4)
- October 2009 (2)
- September 2009 (1)
Zend Framework Application Progress
Tonight's programming lessons included
- Removing Decorators (dt, dd HTML tags) from Zend_Form_Element_Hidden types. There are several Decorators by using
removeDecorator
$addressid = new Zend_Form_Element_Hidden('addressid'); $addressid->setAttrib('id', 'form-addressid') ->removeDecorator('HtmlTag') ->removeDecorator('Label');
- Escaping output (removing slashes i.e. O'reilly would be stored in the DB as O\'reilly). We want to just show O'reilly to the visitor.
Normally in the view you would just enter
$this->escape($data);
But, I was using a View Helper so I needed to add some special sauce to the view helper to get it to know how to escape.
class Zend_View_Helper_AddressHtml { public $view; public function addressHtml($data) { $this->view->escape($data['street']); } // This will set the view variable so you can use it above public function setView(Zend_View_Interface $view) { $this->view = $view; } }
Also, to alter the default way to strip out slashes you would use the
init()method in the controller
public function init() { $this->view->setEscape('stripslashes'); }
Credits:
Matthew Weier O'Phinney
ZF Forums - Force Zend_DB Query to return an object instead of a select
$db->setFetchMode(Zend_db::FETCH_OBJ);
Comments
Post new comment