Zend Framework Application Progress
Hold on Cowboy
This blog post is pretty old. Be careful with the information you find in here. The Times They Are A-Changin'
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.
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
Credits: [Matthew Weier O’Phinney] devzone.zend.com/article/3412
- Force Zend_DB Query to return an object instead of a select
$db->setFetchMode(Zend_db::FETCH_OBJ);