Zend_Form_Decorator_ViewHelper::getElementAttribs PHP Method

getElementAttribs() public method

Set id to element name and/or array item.
public getElementAttribs ( ) : array
return array
    public function getElementAttribs()
    {
        if (null === ($element = $this->getElement())) {
            return null;
        }
        $attribs = $element->getAttribs();
        if (isset($attribs['helper'])) {
            unset($attribs['helper']);
        }
        if (method_exists($element, 'getSeparator')) {
            if (null !== ($listsep = $element->getSeparator())) {
                $attribs['listsep'] = $listsep;
            }
        }
        if (isset($attribs['id'])) {
            return $attribs;
        }
        $id = $element->getName();
        if ($element instanceof Zend_Form_Element) {
            if (null !== ($belongsTo = $element->getBelongsTo())) {
                $belongsTo = preg_replace('/\\[([^\\]]+)\\]/', '-$1', $belongsTo);
                $id = $belongsTo . '-' . $id;
            }
        }
        $element->setAttrib('id', $id);
        $attribs['id'] = $id;
        return $attribs;
    }

Usage Example

コード例 #1
0
 /**
  * Get element attributes
  *
  * @return array
  */
 public function getElementAttribs()
 {
     if (null === $this->_attribs) {
         $this->_attribs = parent::getElementAttribs();
         if (array_key_exists('dijitParams', $this->_attribs)) {
             $this->setDijitParams($this->_attribs['dijitParams']);
             unset($this->_attribs['dijitParams']);
         }
     }
     return $this->_attribs;
 }
All Usage Examples Of Zend_Form_Decorator_ViewHelper::getElementAttribs