Twitter_Bootstrap_Form::render PHP Method

render() public method

Render form
public render ( Zend_View_Interface $view = null ) : string
$view Zend_View_Interface
return string
    public function render(Zend_View_Interface $view = null)
    {
        /**
         * Getting elements.
         */
        $elements = $this->getElements();
        foreach ($elements as $eachElement) {
            /**
             * Add required attribute to required elements
             * https://github.com/manticorp
             */
            if ($eachElement->isRequired()) {
                $eachElement->setAttrib('required', '');
            }
            /**
             * Removing label from buttons before render.
             */
            if ($eachElement instanceof Zend_Form_Element_Submit) {
                $eachElement->removeDecorator('Label');
            }
            /**
             * No decorators for hidden elements
             */
            if ($eachElement instanceof Zend_Form_Element_Hidden) {
                $eachElement->clearDecorators()->addDecorator('ViewHelper');
            }
            /**
             * No decorators for hash elements
             */
            if ($eachElement instanceof Zend_Form_Element_Hash) {
                $eachElement->clearDecorators()->addDecorator('ViewHelper');
            }
        }
        /**
         * Rendering.
         */
        return parent::render($view);
    }

Usage Example

 public function render(Zend_View_Interface $view = null)
 {
     foreach ($this->getElements() as $element) {
         $label = $element->getLabel();
         if (!empty($label)) {
             $element->setAttrib('placeholder', $label);
         }
     }
     /**
      * Rendering.
      */
     return parent::render($view);
 }