This is the API documentation for concrete5 version 5.6 and earlier. View Current API Documentation
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 
<?php
defined('C5_EXECUTE') or die("Access Denied.");
class Concrete5_Helper_Form_Attribute {
    
    protected $obj;
    
    public function reset() {
        unset($this->obj);
    }
    
    public function setAttributeObject($obj) {
        $this->obj = $obj;
    }
    
    public function display($key, $required = false, $includeLabel = true, $template = 'composer') {
        if (is_object($key)) {
            $obj = $key;
        } else {
            $oclass = get_class($this->obj);
            switch($oclass) {
                case 'UserInfo':
                    $class = 'UserAttributeKey';
                    break;
                default:
                    $class = $oclass . 'AttributeKey';
                    break;
            }
            $obj = call_user_func(array($class, 'getByHandle'), $key);
        }
        
        if (!is_object($obj)) {
            return false;
        }
        
        if (is_object($this->obj)) {
            $value = $this->obj->getAttributeValueObject($obj);
        }
        
            $controlGroupCssClass = preg_replace('/\W+/','',strtolower(strip_tags($obj->atHandle))) . ' '.$obj->akHandle;
        
        $html = '<div class="control-group '.$controlGroupCssClass.'">';
        if ($includeLabel) {
            $html .= $obj->render('label', false, true);
        }
        if ($required) {
            $html .= ' <span class="ccm-required">*</span>';
        }
        $html .= '<div class="controls">';
        $html .= $obj->render($template, $value, true);
            
        $html .= '</div></div>';
        
        return $html;
    }

}