<?php
    
class attr_color extends attr {

    function getDBType() {
    	return "char(7)";
    }

  	function render_input() {
		$cv = $this->getCurVal();
	    $tpl = '<input type="color" name="'.$this->attr_name.'"  id="'.$this->attr_name.'" value="'.$cv.'">';
		return $tpl;
    }

    function render_text( $crop = false ) {
    	if ($crop) {
    		$color = $this->getCurVal();
    		if ($color) {
    			return '<span style="background:'.$color.'; color: '.$color.';" class="text-monospace">'.$color.'</span>';
    		} else {
    			return '';
    		}
    	}
	    return $this->getCurVal();
    }
}

?>