Zend Framework Application Progress

Hold on Cowboy

This blog post is pretty old. Be careful with the information you find in here. It's likely dead, dying, or wildly inaccurate.

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 * Force Zend_DB Query to return an object instead of a select $db->setFetchMode(Zend_db::FETCH_OBJ);

Did this help you out? It took me a few days to piece together all this information together, I hope this saves you some time (who knows, maybe the future me will be thankful I wrote this down). Let me know your thoughts. shanestillwell@gmail.com